Python parser and library for hledger journal files — CLI tools, DataFrame export, and a clean data model for the Python ecosystem
Project description
ledgerkit
A Python implementation of the hledger plain-text accounting tool.
Features
- Parse
.journalfiles compatible with the hledger 1.52 format - Comprehensive directive support:
include,account,commodity,payee,alias,P,Y,D,apply account - Core CLI commands:
balance,register,print,accounts,stats,check - Strict mode (
-s) and balance assertions - Multi-commodity balances with tree rollup
- Commodity display style inference and
-coverride flag - Optional pandas DataFrame export (
pip install ledgerkit[pandas]) - Editor-integration layer: lenient parser, round-trip writer,
EditorDocument - Pure Python — no third-party runtime dependencies
- Python 3.8–3.12
Requirements
- Python 3.8+
Installation
pip install ledgerkit
With optional pandas support:
pip install ledgerkit[pandas]
Development install
git clone https://github.com/ctosullivan/ledgerkit.git
cd ledgerkit
pip install -e ".[pandas]"
Usage
CLI
ledgerkit balance myfile.journal
ledgerkit register myfile.journal
ledgerkit accounts myfile.journal
ledgerkit print myfile.journal
ledgerkit stats myfile.journal
You can also invoke ledgerkit as a Python module:
python -m ledgerkit balance myfile.journal
Python library
import ledgerkit
journal = ledgerkit.load("myfile.journal")
accounts = journal.accounts()
balance = journal.balance()
See docs/python-api.md for the full library reference.
Documentation
| Guide | Description |
|---|---|
| docs/getting-started.md | Installation, first run, verification |
| docs/usage.md | CLI commands with examples |
| docs/journal-format.md | Supported journal syntax with annotated examples |
| docs/python-api.md | Python library reference |
Python ecosystem (pandas)
Install the optional pandas extra for DataFrame export:
pip install ledgerkit[pandas]
Then:
import ledgerkit
journal = ledgerkit.load("myfile.journal")
# Export all postings to a DataFrame
df = journal.to_dataframe()
print(df.groupby("account")["amount"].sum())
# Or export directly from a report object
balance_df = journal.balance().to_dataframe()
register_df = journal.register().to_dataframe()
accounts_df = journal.accounts().to_dataframe()
Development
# Run all tests
python -m unittest discover -s tests -t . -v
See dev-docs/architecture.md for module design and dev-docs/api-spec.md for the full API specification.
Hledger Compatibility
See dev-docs/hledger-compatibility.md for which hledger journal features are supported in v1.
Contributing
See CONTRIBUTING.md for pull request guidelines, commit message format, and branch naming. This project follows the Contributor Code of Conduct.
With AI tooling (Claude Code)
Clone the full repository including AI-workflow files:
git clone https://github.com/ctosullivan/ledgerkit.git
Without AI tooling
Use sparse checkout to clone only the source code, tests, and human docs
(excludes CLAUDE.md, dev-docs/, CHANGELOG.md, ROADMAP.md):
git clone --filter=blob:none --sparse https://github.com/ctosullivan/ledgerkit.git
cd ledgerkit
git sparse-checkout set ledgerkit tests docs README.md LICENSE pyproject.toml
Acknowledgements
ledgerkit is a Python implementation inspired by two pioneering plain-text accounting projects. We gratefully acknowledge their authors and contributors.
Ledger
John Wiegley created Ledger, the original plain-text double-entry accounting tool, which established the journal file format and accounting model that this ecosystem is built upon.
https://github.com/ledger/ledger
hledger
Simon Michael created hledger, a Haskell implementation of Ledger's concepts, which has since evolved its own rich feature set and extensive documentation. ledgerkit's journal format support is modelled primarily on the hledger 1.52 specification.
https://github.com/simonmichael/hledger
A full list of hledger contributors can be found at:
https://github.com/simonmichael/hledger/blob/main/doc/CREDITS.md
Their work — and the broader plain-text accounting community — makes ledgerkit possible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ledgerkit-1.0.0.dev1.tar.gz.
File metadata
- Download URL: ledgerkit-1.0.0.dev1.tar.gz
- Upload date:
- Size: 69.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a60431fd6a7aeaf7b4d4614621060858eb3832d8c65888ac75fed742b3237087
|
|
| MD5 |
e951ab2e6a50d7c0e92f8aaa45b30999
|
|
| BLAKE2b-256 |
7ae656f6dc9b07dc0c1640a80d4efb538b16f77231978c1ca993dbc8f19f5d9a
|
Provenance
The following attestation bundles were made for ledgerkit-1.0.0.dev1.tar.gz:
Publisher:
publish.yml on ctosullivan/ledgerkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledgerkit-1.0.0.dev1.tar.gz -
Subject digest:
a60431fd6a7aeaf7b4d4614621060858eb3832d8c65888ac75fed742b3237087 - Sigstore transparency entry: 1744425787
- Sigstore integration time:
-
Permalink:
ctosullivan/ledgerkit@572e77bd856ebcd9e499fa2613a3119dc298a650 -
Branch / Tag:
refs/tags/v1.0.0.dev1 - Owner: https://github.com/ctosullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@572e77bd856ebcd9e499fa2613a3119dc298a650 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ledgerkit-1.0.0.dev1-py3-none-any.whl.
File metadata
- Download URL: ledgerkit-1.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 58.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42749cd4811d47cbcf88730cf87b9594f68da760a82a9cc36089b05ba5b772a4
|
|
| MD5 |
fcb4424de7dee52fc29cf054bddb3a10
|
|
| BLAKE2b-256 |
cb24a8a6c5c1b281230597632c53af02ac892567a9491e4d89796a077974b074
|
Provenance
The following attestation bundles were made for ledgerkit-1.0.0.dev1-py3-none-any.whl:
Publisher:
publish.yml on ctosullivan/ledgerkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledgerkit-1.0.0.dev1-py3-none-any.whl -
Subject digest:
42749cd4811d47cbcf88730cf87b9594f68da760a82a9cc36089b05ba5b772a4 - Sigstore transparency entry: 1744425857
- Sigstore integration time:
-
Permalink:
ctosullivan/ledgerkit@572e77bd856ebcd9e499fa2613a3119dc298a650 -
Branch / Tag:
refs/tags/v1.0.0.dev1 - Owner: https://github.com/ctosullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@572e77bd856ebcd9e499fa2613a3119dc298a650 -
Trigger Event:
push
-
Statement type: