Skip to main content

A lightweight Python package for easy reading and writing of JSON, JSONL, and Pickle files.

Project description

whywhytools

whywhytools is a lightweight Python package for reading and writing JSON, JSON Lines (.jsonl), and Pickle files. It provides simple and intuitive APIs for handling these common data formats.

Installation

You can install this package using pip:

pip install whywhytools

Quickstart

JSON Lines (.jsonl)

Handle .jsonl files, supporting read, write, and append operations.

Write JSONL File
from whywhytools import write_jsonl

data = [
    {'id': 'data-1', 'text': 'hello world'},
    {'id': 'data-2', 'text': 'whywhytools is awesome'}
]

# Write to file
write_jsonl(data, 'output.jsonl') # [INFO] save to output.jsonl

# If file exists
write_jsonl(data, 'output.jsonl') # [INFO] output.jsonl already exists.

# Force overwrite existing file
write_jsonl(data, 'output.jsonl', force=True) # [INFO] save to output.jsonl

# Silent mode (not print any message)
write_jsonl(data, 'output.jsonl', force=True, silent=True)
Append to JSONL File
from whywhytools import append_jsonl

new_data = [{'id': 'data-3', 'text': 'new line'}]
append_jsonl(new_data, 'output.jsonl')
Read JSONL File
from whywhytools import read_jsonl

data = read_jsonl('output.jsonl')
print(data)
# [{'id': 'data-1', 'text': 'hello world'}, {'id': 'data-2', 'text': 'whywhytools is awesome'}, {'id': 'data-3', 'text': 'new line'}]

JSON (.json)

Handle standard .json files.

Write JSON File
from whywhytools import write_json

data = {'project': 'whywhytools', 'version': '0.1.0'}

# Write to file
write_json(data, 'config.json')
Read JSON File
from whywhytools import read_json

config = read_json('config.json')
print(config)

Pickle (.pkl)

Handle Python's pickle serialization format.

Save Pickle File
from whywhytools import save_pickle

model_data = {'weights': [0.1, 0.5, 0.9], 'bias': 0.01}
save_pickle(model_data, 'model.pkl')
Load Pickle File
from whywhytools import load_pickle

data = load_pickle('model.pkl')
print(data)

License

MIT

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

whywhytools-0.6.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whywhytools-0.6.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file whywhytools-0.6.2.tar.gz.

File metadata

  • Download URL: whywhytools-0.6.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for whywhytools-0.6.2.tar.gz
Algorithm Hash digest
SHA256 fe79100ea3727bc3ac991871a030a1a522735c047bc5e896246adbc8a014e7ec
MD5 2b287718872a4024f7d302bd8c833784
BLAKE2b-256 9e9231b5baca1a17c6a29eec58a1b81f0bcf9f1dd4bc5977cd981af2ebcafc46

See more details on using hashes here.

Provenance

The following attestation bundles were made for whywhytools-0.6.2.tar.gz:

Publisher: publish_to_pypi.yaml on whywhybug/whywhytools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file whywhytools-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: whywhytools-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for whywhytools-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f4416e607766492c14c47607f26a3dcaf3ff92536fc532155626583aee1ec11
MD5 514102e9f4faa896c6101d1b6c69724d
BLAKE2b-256 ff4029d6c1097a79bfbd8c39113adffb448ec4d4688cebf90e1238f4d79c9506

See more details on using hashes here.

Provenance

The following attestation bundles were made for whywhytools-0.6.2-py3-none-any.whl:

Publisher: publish_to_pypi.yaml on whywhybug/whywhytools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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