Skip to main content

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 :).

Example usage

Read a journal

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.1.tar.gz (1.6 kB view hashes)

Uploaded Source

Built Distribution

ledger_reader-0.1-py3-none-any.whl (1.6 kB view hashes)

Uploaded Python 3

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