CSV export with both accounts of a transactions

211 views
Skip to first unread message

Varac

unread,
Nov 30, 2021, 1:41:25 PM11/30/21
to Beancount
For tax consultency I need to export an csv file which lists my
transactions in this format (only fields relevant to my question given):

date, amount, account_from, account_to

I.e. given this transaction:


2021-11-30 txn "Shopping"
Assets:Beans -10 EUR
Expenses:Unneccessary 4 EUR
Expenses:Wtf 6 EUR


I want a csv export like this:

2021-11-30, 4, Asset:Beans, Expenses:Unneccessary
2021-11-30, 6, Asset:Beans, Expenses:Wtf

Is there any way getting this out of a bean-query ?
Or what would be the best approach ?
Looking forward to some serious beancount SQL wizardry above my horizon !

Thanks for any hints, Varac

Ben Blount

unread,
Nov 30, 2021, 3:53:06 PM11/30/21
to Beancount
If you are at all familiar with Python, I'd do this by hand in code by looping over the transactions and postings within rather than trying to fiddle with BQL.
Once you are familiar with a few API pieces (loader.load_file and filtering to get the Transactions out of entries), this is a quick task.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/beancount/89497063-12be-83cf-8953-d2e7090f90f0%40varac.net.

Daniele Nicolodi

unread,
Nov 30, 2021, 4:07:21 PM11/30/21
to bean...@googlegroups.com
I don't think this is possible with the data model used in bean-query
and I don't think there is an existing tool to flatten a Beancount
ledger into the required format. Writing such a tool without introducing
some assumptions could be fairly complex.

I would write a script that loads the ledger and iterates the
transactions and produces the desired table.

Cheers,
Dan

Martin Blais

unread,
Nov 30, 2021, 8:32:58 PM11/30/21
to Beancount
Well you have everything except the assets account:
bean-query test.beancount 'select date, number, account where account ~ "Expenses:" '

Just write a bit of Python.




--
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.
Reply all
Reply to author
Forward
0 new messages