Skip to main content

sourceledger

python license DOI OpenSSF Scorecard OpenSSF Best Practices CodSpeed

Build a dataset from published sources and keep a record of the downloads behind it.

sourceledger is a Python library and command for researchers who combine other people's CSV, JSON, Excel or binary files. List the sources and reuse terms in sources.toml, then:

  • fetch downloads the files and records their URLs, dates and SHA-256 checksums.
  • build writes tables with provenance columns, or copies file sources unchanged.
  • validate checks the outputs against the downloads and the manifest.
  • release writes the folder to publish, without the sources whose terms forbid it, and checks it.

Each table row identifies its download. A datapackage.json describes the outputs. The documentation website follows a source through a publisher's revision. In Python, align_rows() matches two versions by the keys you name, keeping the full rows and their provenance. Your code decides which values count as changed.

Install

uv tool install sourceledger

For a Python project that imports the library, use uv add sourceledger instead. Use sourceledger[xlsx] in either command to read Excel files, sourceledger[parquet] to write Parquet outputs, or sourceledger[release] to check RO-Crate and Croissant metadata. Python 3.12 or later is required; Linux, macOS and Windows are supported. This README follows main, including unreleased features.

Quick start

Write a sources.toml in the project root (sourceledger init writes a starter):

[[source]]
id = "co2"
status = "implemented"
url = "https://raw.githubusercontent.com/datasets/co2-ppm/main/data/co2-annmean-mlo.csv"
vintage = "main branch, unversioned"
terms = "ODC-PDDL-1.0 (datasets/co2-ppm package; original data from NOAA GML)"
terms_url = "https://opendatacommons.org/licenses/pddl/"
license = "PDDL-1.0"
redistribute = true

Then run the stages from that directory:

sourceledger fetch
sourceledger build
sourceledger validate

sourceledger fetch --help lists one stage's options, and --dry-run on fetch, record and build shows what they would write. Exit code 1 means validate or release found problems, 2 a usage error and 3 that a stage could not run; see options and exit codes.

For Parquet outputs, set output_format = "parquet" before the first [[source]] table in sources.toml, after installing the Parquet extra above. CSV remains the default. Parquet writing and validation use batches of at most 10,000 rows; see table memory limits.

sourceledger reads CSV (gzipped or not), JSON and Excel, by each source's format or its URL's extension. Set format = "file" to keep a raster, archive or other file unchanged. For another table format, see custom readers. If another tool downloads a source, record its file instead of fetching it.

What to commit

Commit sources.toml and data/fetches.jsonl. The log holds checksums and URLs, not data: it's the history of every version you have fetched.

Build output is a local working dataset. A file source is copied unchanged, including when redistribute = false. Check reuse terms before publication.

Keep data/raw/ and data/processed/ out of git, so the repository never redistributes a publisher's data. The .fetch.json records live in data/raw/ too, so a fresh clone runs fetch before build and validate.

Documentation

Project status

Stability

Until 1.0, the public API is sourceledger's __all__, the keys of sources.toml, the format of fetch records and the log, and the CLI's stages, options, exit codes and --json reports. A breaking change to any of them comes only in a minor version, listed in CHANGELOG.md, with a warning first where that's cheap. Older fetch logs stay readable. A record written by record(), or with parameters, is not readable by 0.4.0: after a downgrade, run fetch again.

Roadmap

  • An error class per kind of failure in the other stages, under ValueError and OSError, once a caller needs to tell them apart. This will not break code that catches the base classes.
  • A review by pyOpenSci once the project has users besides its own template.

Not planned:

  • Templated, paginated or parallel downloads, an update command, or a plugin per download tool. Other tools fetch those files, and record logs them (0005).

Ideas and requests are welcome as issues.

Social card

docs/assets/og.png is the 1200x630 card shown when the link is shared. It is rendered from docs/og-card.html, which draws the chain of custody of the revision example: the 2023 value and the SHA-256 of the download, each before and after the publisher's change. Edit the HTML, then run:

just og-card

Zensical serves docs/assets/, and docs-overrides/main.html holds the tags. Rendering a new card needs Node and pnpm for the Playwright screenshot command.

Development

You need uv and just. just check also builds the documentation site.

uv sync
just check

Zensical builds the Markdown in docs/, including search and the Python API reference. just docs builds it into _docs/ in strict mode. just docs-serve previews it locally. Every push to main deploys it to GitHub Pages at https://simonvanlierde.com/sourceledger/.

Contributing covers hooks, coding standards and tests. Governance explains project decisions. Report vulnerabilities through Security.

License

MIT. See LICENSE.

Metadata

Release files for sourceledger 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sourceledger 0.6.0
File Size Uploaded Provenance Actions
sourceledger-0.6.0.tar.gz 65.1 kB With provenance Details for sourceledger-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sourceledger 0.6.0
File Interpreter ABI Platform Actions
sourceledger-0.6.0-py3-none-any.whl Python 3 none any Details for sourceledger-0.6.0-py3-none-any.whl

Total release size: 135.3 kB

Release files / sourceledger-0.6.0.tar.gz

Download URL sourceledger-0.6.0.tar.gz
Size 65.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a884359a23559fbfb1da19f79b244758d23f03fc63934689b25cf1c1b97c9960
BLAKE2b-256 checksum
How to use checksums
3f9c7067c45d4698bb10919874befdae2fb7c7ce254bce109e76f3b7d374712d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / sourceledger-0.6.0-py3-none-any.whl

Download URL sourceledger-0.6.0-py3-none-any.whl
Size 70.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c8046b13a842d80dae8bbf4c8a32e4c9c1893625c51fdfe7c5eb6958b8cd4f9
BLAKE2b-256 checksum
How to use checksums
5175f91df713c07704d51e37097378b0784acbc2559875e440fb1980be913412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for sourceledger 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sourceledger-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page