Simplify using JSONLines files alongside dataclasses.
Project description
jldc
Simplify using JSON Lines files alongside python dataclass ([PEP-557][pep-557]) objects, with convenient one-line reads/writes.
usage
Import the library and save/load lists of dataclasses or dictionaries with a single line.
from jldc.core import load_jsonl, save_jsonl
from dataclasses import dataclass
@dataclass
class Person:
name: str
age: int
save_jsonl("people.jsonl", [Person("Alice", 24), Person("Bob", 32)])
data = load_jsonl("people.jsonl", [Person])
print(data)
installation
Install directly from GitHub, using pip:
pip install 'git+https://github.com/itsluketwist/jldc'
Use the ml
extra to encode/decode the numpy.ndarray
type:
pip install 'jldc[ml]@git+https://github.com/itsluketwist/jldc'
development
Clone the repository code:
git clone https://github.com/itsluketwist/jldc.git
Once cloned, install the package locally in a virtual environment:
python -m venv venv
. venv/bin/activate
pip install -e ".[dev,ml]"
Install and use pre-commit to ensure code is in a good state:
pre-commit install
pre-commit autoupdate
pre-commit run --all-files
testing
Run the test suite using:
pytest .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jldc-0.0.5.tar.gz
.
File metadata
- Download URL: jldc-0.0.5.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de9990a4fb34f8bfd8cb245cbdc1a9353ba155bde46496b7d7c8cfd0e2f43082 |
|
MD5 | 518996035152e796452b230a4e2d4fbc |
|
BLAKE2b-256 | d0889275fdcadd7e238170cf3047a75c67f7780eb7ce9a56701356ee15ff8252 |
File details
Details for the file jldc-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: jldc-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fba03ee73f74983ca4a2d85abd53003198a912fb0a8a43041c89afe5b43c1525 |
|
MD5 | 44b578a5de1c0b794daa71f429bebc07 |
|
BLAKE2b-256 | 440848003ddaf921b557f17e55559ddbb66b8aeefc11959f008f56326998bbd2 |