Ledger::Parser - Parse Ledger journals
This document describes version 0.04 of Ledger::Parser (from Perl distribution Ledger-Parser), released on 2015-03-26.
use Ledger::Parser; my $ledgerp = Ledger::Parser->new( # year => undef, # default: current year # input_date_format => 'YYYY/MM/DD', # or 'YYYY/DD/MM', ); # parse a file my $journal = $ledgerp->read_file("$ENV{HOME}/money.dat"); # parse a string $journal = $ledgerp->read_string(<<EOF); ; -*- Mode: ledger -*- 09/06 dinner Expenses:Food $10.00 Expenses:Tips 5000.00 IDR ; 5% tip Assets:Cash:Wallet 2013/09/07 opening balances Assets:Mutual Funds:Mandiri 10,305.1234 MFEQUITY_MANDIRI_IAS Equity:Opening Balances P 2013/08/01 MFEQUITY_MANDIRI_IAS 1,453.8500 IDR P 2013/08/31 MFEQUITY_MANDIRI_IAS 1,514.1800 IDR EOF
See Ledger::Journal for available methods for the journal object.
This module parses Ledger journal into Ledger::Journal object. See http://ledger-cli.org/ for more on Ledger, the command-line double-entry accounting system software.
Ledger 3 can be extended with Python, and this module only supports a subset of Ledger syntax, so you might also want to take a look into the Python extension. However, this module can also modify/write the journal, so it can be used e.g. to insert transactions programmatically (which is my use case and the reason I first created this module).
This is an inexhaustive list of things that are not currently supported:
Costs & prices
For example, things like:
2012-04-10 My Broker Assets:Brokerage 10 AAPL @ $50.00 Assets:Brokerage:Cash
Automated transaction
Periodic transaction
Expression
Various commands
Including but not limited to: assert, C (currency conversion), ...
Ledger accepts dates in the form of yearless (e.g. 01/02, 3-12) or with 4-digit year (e.g. 2015/01/02, 2015-3-12). Month and day can be single- or double-digits. Separator is either - or /.
-
/
When year is omitted, year will be retrieved from the year attribute.
year
The default format is month before day (YYYY/MM/DD), but you can also use day before month (YYYY/DD/MM).
YYYY/MM/DD
YYYY/DD/MM
Only used when encountering a date without year.
Create a new parser instance.
Please visit the project's homepage at https://metacpan.org/release/Ledger-Parser.
Source repository is at https://github.com/perlancar/perl-Ledger-Parser.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Ledger-Parser
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Ledger::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ledger::Parser
CPAN shell
perl -MCPAN -e shell install Ledger::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.