Skip to content

JSON-lines and recursive reading of json-files in a path.

License

Notifications You must be signed in to change notification settings

cherenkov-plenoscope/json_utils

Repository files navigation

Json-utils

TestStatus PyPiStatus BlackStyle BlackPackStyle MITLicenseBadge

numpy

Uses json_numpy for transparent loads and dumps of lists into numpy-arrayrs if the dtype is either purely int or float.

trees

Recursively read (or write) .json files in a tree of directories.

lines

JSON-lines or .jsonl is a powerful extension to the JSON-family.

import json_utils as ju

with ju.lines.open("my-items.jsonl.gz", mode="w|gz") as jl:
    for i in range(100):
        jl.write({"number": i})

with ju.lines.open("my-items.jsonl.gz", mode="r|gz") as jl:
    for obj in jl:
        print("item", obj["number"])