A simple parser for hledger journal files.
Project description
Ledger Reader
A simple parser for hledger journal files. It's always fun to play with rply and use a simple grammar. PR's welcome :).
Install
pip install ledger-reader
Example usage
Read a journal
from ledger_reader import LedgerReader
reader = LedgerReader()
journal = reader.parse_file('bank.journal')
for entry in journal:
print(entry.date, entry.description)
for transaction in entry.transactions:
print(f'{transaction.account} {transaction.currency} {transaction.amount}')
print()
Append to a journal
from datetime import date
from ledger_reader import Entry, Transaction
entry = Entry(
date(2022, 3, 5),
'Cash Transfer',
transactions=[
Transaction('assets:bank:boa:checking', '$', -5000),
Transaction('assets:bank:boa:savings')
]
)
with open('bank.journal', 'a') as fp:
fp.write(f'\n{entry}')
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
ledger_reader-0.7.tar.gz
(4.4 kB
view details)
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 ledger_reader-0.7.tar.gz.
File metadata
- Download URL: ledger_reader-0.7.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d217ed0990e081ef3f04fdffbf9f41770dde538d339c28f725c3b15e1d8d1a0a
|
|
| MD5 |
6e1cb6d40109bcd6cf079ac2fd5f96d9
|
|
| BLAKE2b-256 |
fec1884646f4a3570bb05fa611f94b8ab320a1b29c7425294ae2b8a21409b0ba
|
File details
Details for the file ledger_reader-0.7-py3-none-any.whl.
File metadata
- Download URL: ledger_reader-0.7-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef34b51286577c52e03a581da2a9f82451a7c5750367223d164c8c56b616153c
|
|
| MD5 |
8d36475f3c0ada140d46d85ec4214652
|
|
| BLAKE2b-256 |
69ec9aca4cc90bbed02dba41253f03c0d7f6d0ed393b234fae87aa004c82941d
|