Combining multiple .beancount files

60 views
Skip to first unread message

Dan Andersson

unread,
Feb 7, 2024, 3:59:28 PMFeb 7
to Beancount
Hello,

I have three files: 1.beancount, 2.beancount, 3.beancount
Within each file we have a correct date order, but the three files' date ranges could overlap.

How could I combine these files into a single result file while making sure the result has the correct date order?

Thanks,
DA

Daniele Nicolodi

unread,
Feb 7, 2024, 4:41:37 PMFeb 7
to bean...@googlegroups.com
Beancount does not care about the order in which the entries are ordered
by date in the source files (well, almost, the ordering in the source
file matters to resolve ties in transaction dates, but in the almost
totality of cases this is not a problem).

Sorting the entries by date is necessary only for your convenience.

The easiest way to combine the files is to use the Beancount parser to
parse the entries and then serialize them again to file. I've posted
very simple scripts that does just this a couple of times on the mailing
list already. However, this does not preserve everything that may be in
the source files (comments, formatting, some syntax constructs...).

autobean-format is a tool developed outside Beancount that may do this.

I have some elisp code that sorts transactions in Emacs buffers, when I
need to do this on smallish portions of ledgers (I should probably merge
it into beancount-mode at some point).

Cheers,
Dan

Reply all
Reply to author
Forward
0 new messages