#parser #ledger #ledger-cli

ledger-parser

Rust library for parsing ledger cli (https://www.ledger-cli.org/) input files

5 stable releases

2.2.0 Feb 17, 2019
2.1.0 Nov 5, 2018
2.0.0 Oct 23, 2018
1.0.1 Oct 22, 2018

#111 in Parser tooling

33 downloads per month

Unlicense

45KB
1K SLoC

ledger-parser

Crates.io Version Docs.rs Version License Unlicense

Rust library for parsing Ledger-cli input files.

File format

Only a subset of the ledger-cli's file format is implemented.

Supported elements:

  • Line comments (starting with: ; # % | *)

  • Inline comments (starting with ;)

  • Transaction headers with format:

    DATE[=EDATE] [*|!] [(CODE)] DESC
    
  • Transaction postings with format (minimum two spaces or one tab between ACCOUNT and AMOUNT):

      ACCOUNT  AMOUNT [; NOTE]
    

    Note that the AMOUNT field is always required.

  • Commodity prices with format:

    P DATE SYMBOL PRICE
    

Example

extern crate ledger_parser;

let result = ledger_parser::parse(r#"; Example 1
2018-10-01=2018-10-14 ! (123) Description
  ; Transaction comment
  TEST:Account 123  $1.20
  ; Posting comment
  TEST:Account 345  -$1.20"#);

Dependencies

~2MB
~38K SLoC