Utilities for using JSONL (JSON lines) file type with Python.
- Python 3.6+
- Python modules from the
requirements.txt
Dowload and install the dependencies with the command:
$ python -m pip install -r requirements.txt
Install the module.
pip install git+https://github.com/MartinKondor/jsonl.git
Import and define a list of objects to work with.
from typing import List, Any
from jsonl import jsonl
a: List[Any] = [
{"first_name": "Joe1", "last_name": "Doe1"},
{"first_name": "Joe2", "last_name": "Doe2"},
{"first_name": "Joe3", "last_name": "Doe3"},
]
Save the object to a file:
jsonl.dump(a, "dummy_data.jsonl")
Append an object to a file (works even if the file didn't exist).
obj: Any = {"first_name": "Joe_Appended", "last_name": "Doe_Appended"}
jsonl.append(obj, "dummy_data.jsonl")
Load a jsonl file:
data = jsonl.load("dummy_data.jsonl")
Print out the JSON object nicely:
jsonl.print(data)
This project is open for any kind of contribution from anyone.
- Fork this repository
- Create a new branch (optional)
- Clone it
- Make your changes
- Upload them
- Make a pull request here
Copyright (C) 2023-2024 Martin Kondor.
See the LICENSE file for details.