# Explorer.DataFrame - load\_ndjson json

**URL:** <https://forum.elixirforum.com/t/explorer-dataframe-load-ndjson-json/56679>\
**Category:** Questions\
**Tags:** explorer\
**Created:** [June 24, 2023, 10:20pm UTC](https://forum.elixirforum.com/t/explorer-dataframe-load-ndjson-json/56679 "2023-06-24T22:20:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![imed-code](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/imed-code/32/30799_2.png) [@imed-code](https://forum.elixirforum.com/u/imed-code)\
**Post date:** [June 24, 2023, 10:20pm UTC](https://forum.elixirforum.com/t/explorer-dataframe-load-ndjson-json/56679/1 "2023-06-24T22:20:25Z")

</div>

Hello,

I’m trying to load a json API message with Explorer.DataFrame.

My api is returning a list like bellow:

```elixir
resp = [%{"idade" => "8", "nome" => "Mirela"}, %{"idade" => "40", "nome" => "Sergio"}]

```

When I try to run the following code:

```elixir
require Explorer.DataFrame, as: DF
DF.load_ndjson!(Jason.encode!(resp), lazy: true)

```

I got an error:

```elixir
** (ErlangError) Erlang error: :nif_panicked
    (explorer 0.5.7) Explorer.PolarsBackend.Native.df_load_ndjson("...

```

But if I change to read the first element it works as well.

```elixir
require Explorer.DataFrame, as: DF
DF.load_ndjson!(Jason.encode!(List.first(resp)))

```

How to read the entire data ?

Thank you.

---

<div class="post-metadata">

**Author:** ![al2o3cr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/32/3457_2.png) [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Post date:** [June 24, 2023, 11:43pm UTC](https://forum.elixirforum.com/t/explorer-dataframe-load-ndjson-json/56679/2 "2023-06-24T23:43:19Z")

</div>

The ndjson parser expects JSON objects separated by newlines - for instance, here’s an example from Explorer’s tests:

[https://github.com/elixir-nx/explorer/blob/1db7146d83965f6446c4ab52816be4993952724c/test/explorer/data\_frame/ndjson\_test.exs#L36-L47](https://github.com/elixir-nx/explorer/blob/1db7146d83965f6446c4ab52816be4993952724c/test/explorer/data_frame/ndjson_test.exs#L36-L47)

That is not what `Jason.encode!(resp)` will produce - that result will have `[` at the beginning and `,` between the objects. You’d need to encode _each_ item in `resp` separately.

HOWEVER

In general, re-encoding like that should make you suspect that you’re not using the best API for your situation.

The better choice is [`Explorer.DataFrame.new`](https://hexdocs.pm/explorer/Explorer.DataFrame.html#new/2-from-tabular), in particular the last example labeled “From row data:”.
