ledger2beancount: ledger to beancount converter

82 views
Skip to first unread message

Martin Michlmayr

unread,
Mar 30, 2018, 8:19:06 AM3/30/18
to bean...@googlegroups.com
I'd like to announce ledger2beancount, a script to convert ledger
files to beancount. It was developed by Stefano Zacchiroli and
myself.

ledger2beancount supports the majority of ledger syntax and features.
It also includes some features to improve the conversion from ledger
to beancount. For example, ledger2beancount has two configurable
mechanisms that let you determine the payee from the narration. We
also try to handle ledger's "A @ B" statements correctly, which can
either mean "A @ B" or "A {B}" in beancount.

I assume most people on this mailing list are already using beancount
but you can tell your friends who still use ledger. ;-)

You can obtain ledger2beancount from
https://github.com/zacchiro/ledger2beancount/

The supported ledger features are described in the README and there's
a manual with detailed descriptions of ledger2beancount's features.
There's also an illustrated example showing some of the differences
between ledger and beancount.

Feedback and improvements to ledger2beancount are welcome (see the
contribution information).

Martin & Zack

--
Martin Michlmayr
http://www.cyrius.com/

Dominik Aumayr

unread,
Mar 30, 2018, 8:29:50 AM3/30/18
to bean...@googlegroups.com
Congrats on this release! :-)

(Logical next step in my head: Writing a beancount plugin that converts a specified ledger-file on-the-fly, which would allow ledger-users to quickly see their ledger-data in Fava.)
> --
> You received this message because you are subscribed to the Google Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
> To post to this group, send email to bean...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/20180330121904.x7cejgoi6qdmmm3h%40jirafa.cyrius.com.
> For more options, visit https://groups.google.com/d/optout.

Stefano Zacchiroli

unread,
Mar 30, 2018, 8:33:36 AM3/30/18
to bean...@googlegroups.com
On Fri, Mar 30, 2018 at 02:29:47PM +0200, Dominik Aumayr wrote:
> (Logical next step in my head: Writing a beancount plugin that
> converts a specified ledger-file on-the-fly, which would allow
> ledger-users to quickly see their ledger-data in Fava.)

Heh, right :) I didn't think of that, but FWIW I've been using
ledger2beancount[^] to do precisely that for almost 3 years now. My main
input format is still Ledger-CLI (for various reasons that are beside
the point here), but I automatically convert to Beancount upon git push
to my personal repo using ledger2beancount, and have a Fava instance
running on top of it. It works like a charm.

Cheers

[^]: well, a preliminary, ad-hoc version of it written only for my
needs, that Martin has then converted to a amazing general-purpose tool
--
Stefano Zacchiroli . za...@upsilon.cc . upsilon.cc/zack . . o . . . o . o
Computer Science Professor . CTO Software Heritage . . . . . o . . . o o
Former Debian Project Leader . OSI Board Director . . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »

Saša Janiška

unread,
Mar 30, 2018, 8:36:14 AM3/30/18
to bean...@googlegroups.com
Dominik Aumayr <dom...@aumayr.name> writes:

> (Logical next step in my head: Writing a beancount plugin that
> converts a specified ledger-file on-the-fly, which would allow
> ledger-users to quickly see their ledger-data in Fava.)

...while stll being able to do (envelope) budgeting & forecasting with
(h)ledger. ;)


Sincerely,
Gour

--
One who sees inaction in action, and action in inaction,
is intelligent among men, and he is in the transcendental position,
although engaged in all sorts of activities.

Martin Blais

unread,
Mar 30, 2018, 11:27:49 PM3/30/18
to Beancount
Dear Comrades,
This is doubleplusgood, and even more. Congrats on shipping! :-)
Maybe this will even contribute to keeping Perl alive for another century or two.

I've added a link to the Contributions doc.
Thanks for building and sharing useful stuff,




--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscribe@googlegroups.com.

Martin Blais

unread,
Mar 30, 2018, 11:38:14 PM3/30/18
to Beancount
I think I would implement this differently than it does it.
It seems to me the "envelope" method could be implemented with regular transaction (i.e., without resorting to "virtual" ones) by doing a few things:
- automatically generating most of the transactions spending off the envelopes, so you don't have to
- adding the ability to toggle on and off the budgeting transactions in order to render balance sheets with and without the envelopes (that's mainly a reporting feature)
(It seems to be this could be done with a plugin today perhaps.)




--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscribe@googlegroups.com.

To post to this group, send email to bean...@googlegroups.com.

Saša Janiška

unread,
Mar 31, 2018, 8:47:17 AM3/31/18
to bean...@googlegroups.com
Martin Blais <bl...@furius.ca> writes:

> I think I would implement this differently than it does it.
> It seems to me the "envelope" method could be implemented with
> regular transaction (i.e., without resorting to "virtual" ones) by
> doing a few things:
> - automatically generating most of the transactions spending off the
> envelopes, so you don't have to
> - adding the ability to toggle on and off the budgeting transactions
> in order to render balance sheets with and without the envelopes
> (that's mainly a reporting feature)
> (It seems to be this could be done with a plugin today perhaps.)

It sounds very good and I'm eagerly awaiting to see something to test...


Sincerely,
Gour

--
It is far better to discharge one's prescribed duties, even though
faultily, than another's duties perfectly. Destruction in the course
of performing one's own duty is better than engaging in another's duties,
for to follow another's path is dangerous.

Martin Michlmayr

unread,
May 1, 2018, 4:19:37 AM5/1/18
to bean...@googlegroups.com
Version 1.1 of ledger2beancount is out now.

You can get it from GitHub:
https://github.com/zacchiro/ledger2beancount

Incompatible changes:

If you already use ledger2beancount, please note that the payee_match
variable changed from a Yaml hash to a list (to make the order
deterministic).

Version 1.1 includes a number of bug fixes and enhancements based on
feedback from users. Here's the changelog:

## 1.1 (2018-05-01)

* Happy International Workers' Day release!
* Handle block comments without indentation correctly
* Preserve comments for postings with lots
* Use beancount's `pushtag/poptag` for ledger's `apply tag`
* Handle `tag` directives with associated commands correctly
* Allow option `link_match` to work with `tag_as_metadata: true`
* Handle posting-level tags without indentation correctly with
`tag_as_metadata: false`
* Ensure `payee_match` is predictable
* Preserve comments for postings with lots
* Embed an optional beancount header to the converted file to
specify beancount options
* Convert ledger metadata keys to valid beancount metadata keys
* Add conversion notes when accounts, commodities or metadata
keys are automatically renamed by ledger2beancount
* Add capability to ignore certain lines
* Keep whitespace intact when renaming account names.
* Improve documentation on assigning payees based on transactions
* Add more test cases
* Run the test suite only if something has changed
Reply all
Reply to author
Forward
0 new messages