Skip to main content

Tools to read and write .son files

Project description

son | sequential object notation

python pypi license code style

What is this?

son is a data format that builds on JSON and adds one feature inspired by YAML: concatenation of objects with ---. Optionally, the delimiter === can be used once per son file to delimit metadata.

Why son?

While JSON is perfect for storing structured data, it is inherently impossible to add new portions of data to a file without reading it first. YAML files on the other hand are self extensible by the --- delimiter, but the flexibility YAML offers makes the files inefficient to parse. They are thus unsuited to store significant amounts of data.

son fills the gap by allowing JSON objects to be concatenated with ---. It thus combines the speed and efficiency of JSON with the sequential extensibility of YAML, see example. It further adds to discern metadata from actual data by using ===.

son does not allow to overwrite data. In order to avoid accidental data loss, metada can only be written to fresh files, whereas data can only be appended to files.

Who needs this?

son originated from the need to store computational data that is produced portion by portion on a computer. The requirements were:

  • Possible to be read by a human,
  • possible to store arbitrary data structures including metadata,
  • easy to write and parse by a computer,
  • efficient to parse to allow files of up to GB size (takes forever to parse with YAML),
  • sequential and incorruptible,
  • resilient to data loss.

Example

This is a valid son string:

{
  "purpose": "store biography data",
  "version": 0.1
}
===
{
  "first name": "Hildegard",
  "second name": "Kneef",
  "age": 93
}
---
{
  "first name": "Wiglaf",
  "second name": "Droste",
  "age": 57
}

It will be parsed into the metadata object, and a list containing the data objects with

import son

metadata, data = son.load('file.son')

Changelog

v.0.3.1: inform before file is read, makes more sense when that takes some time

v.0.3.0: support for reading compressed .bz2 and .gz files

v.0.2.5: progressbar is only shown when a terminal is attached (.isatty())

v.0.2.4: progressbar without external dependency

v.0.2.3: progress.bar prints to stdout instead of stderr

v.0.2.2: optionally be verbose and show progressbar with progress package (optional dependency, install with pip install son[progress])

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

son-0.3.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

son-0.3.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file son-0.3.1.tar.gz.

File metadata

  • Download URL: son-0.3.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-51-generic

File hashes

Hashes for son-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7e3d417a71e612c50bd3703e9b20696886f8ffdb9a055983134109b5cadb7598
MD5 c62fb8b716af8b1b55b0bc44242a7ebe
BLAKE2b-256 f05aac4960347cdb2f386552757510b0d20f8b5f92320fb0152d7a8211f7d575

See more details on using hashes here.

File details

Details for the file son-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: son-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-51-generic

File hashes

Hashes for son-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49b76d9747a07a0d19c270cf3c45d2e565d88ffc9a279a243bfb175bc5aaf559
MD5 edc5317efd4cbbb633183884246111a2
BLAKE2b-256 173145322ff02b3d11b21a0b185d51a6f07b82fe0391bbcc39308ebaeb42a447

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