Skip to main content

A simple Python library for handling jsonlines files.

Project description

jsonl

CI pypi versions codecov license Code style: black Linter: ruff Downloads

About

jsonl is a library that includes useful tools for working with jsonlines data as described: https://jsonlines.org/

Features:

  • 🌎 Offers an API similar to Python's standard json module.
  • 🚀 Supports custom serialization/deserialization callbacks. By default, it uses the standard json module.
  • 🗜️ Enables compression/decompression using gzip, bzip2, and xz formats.
  • 🔧 Load files containing broken lines, skipping any malformed lines.
  • 📦 Provides a simple API for incremental writing to multiple files.

Installation (via pip)

pip install py-jsonl

Getting Started

Dump an iterable to a JSON Lines file.

import jsonl

data = [
    {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]},
    {"name": "May", "wins": []},
]

jsonl.dump(data, "file.jsonl")

Load a JSON Lines file into an iterable of objects.

import jsonl

path = "file.jsonl"
data = [
    {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]},
    {"name": "May", "wins": []},
]

jsonl.dump(data, path)
iterable = jsonl.load(path)
print(tuple(iterable))

Documentation

See project documentation for more details and examples.

Development

Unit tests

(env)$ pip install -r requirements-dev.txt   # Ignore this command if it has already been executed
(env)$ pytest tests/
(env)$ pytest --cov jsonl # Tests with coverge

Build documentation

(env)$ pip install -r requirements-docs.txt   # Ignore this command if it has already been executed
(env)$ mkdocs serve # Start the live-reloading docs server
(env)$ mkdocs build # Build the documentation site

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_jsonl-1.3.9.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

py_jsonl-1.3.9-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file py_jsonl-1.3.9.tar.gz.

File metadata

  • Download URL: py_jsonl-1.3.9.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for py_jsonl-1.3.9.tar.gz
Algorithm Hash digest
SHA256 57a7ca0302ba59dafdf9398cf5a4d2df1d90a31beecf34898abd08a56825855b
MD5 ae33083cd20b20093d200548d6bd81c8
BLAKE2b-256 7d6983026bf9fa9f1841c9085b2c2063a697878da049360b6fd3351b2ac8da8a

See more details on using hashes here.

File details

Details for the file py_jsonl-1.3.9-py3-none-any.whl.

File metadata

  • Download URL: py_jsonl-1.3.9-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for py_jsonl-1.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6f16c2346033be1edb07d6212c1a2fb384155aae6dbeb7d17ccf7e2c68f8b1c8
MD5 01454fb99ffcd9fd3c5a094a9acc48bb
BLAKE2b-256 91aba5d498e1156dac126afb2bb23430cd60447e789222b5960a7ca0c752f5da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page