» pip install jsonlines
» pip install jsonline
The package for json_lines in pip in json-lines. Hence you could install it as:
$ pip install json-lines
It may be appropriate to use an isolated python environment for your particular project if you want to use particular conda libraries but without the whole package. In this instance, you would be able to use virtualenv. This will allow you to create an isolated python environment.
$ pip3 install virtualenv
You can call virtualenv to create a virtual python environment with the working name e.g. myvenv.
$ virtualenv myvenv
From here, you can set your terminal to use this python version. If you are on *nix:
$ which python
/usr/bin/python
$ source myvenv/bin/activate
(myvenv)$ which python
/.../myvenv/bin/python
This article can help you out. https://janakiev.com/blog/jupyter-virtual-envs/
You need to create a virtualenv which will be used by your notebooks.
import jsonlines
with jsonlines.open('example.jsonl', 'r') as jsonl_f:
lst = [obj for obj in jsonl_f]
The jsonl_f is the reader and can be used directly. It contains the lines in the json file.
Simply:
import jsonlines
with jsonlines.open("json_file.json") as file:
data = list(file.iter())
» pip install json-lines
» pip install py-jsonl