# convert json perline to panads data frame

Sometimes we have a file that contains a json object per line. For example log file in json format

```
{foo: 1, bar: 2}
{foo: 3, bar: 4}
```

if we want to read this in python pandas we need to convert it to

```
[
  {foo: 1, bar: 2},
  {foo: 3, bar: 4}
]
```

easy way to do this is with `jq --slurp`

```
$ cat file.json | jq --slurp . > one_array.json
```

then you can read it in python pandas (notebook) like this

```python
sf = pd.read_json('one_array.json')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/analytics/convert-json-perline-to-panads-data-frame.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
