ledger2beancount

82 views
Skip to first unread message

Alen Šiljak

unread,
Apr 23, 2019, 11:03:42 AM4/23/19
to Beancount
As I posted a comment on Reddit, my thoughts went further...

I still find it a bit paradoxical that, to export the data from ledger to beancount, one needs to install the full Perl environment with a bunch of libraries. It's sad that something like this could not have been implemented in Python and shared as modules so that others can transform their source files (or databases) into beancount format.

---

It would be really useful to have a Python module that creates the beancount records and/or the whole file.
I'd love to have something like that in order to implement export from Money Manager Ex or GnuCash. Obviously, ledger2beancount would contain such a module.

Is there a similar thing in beancount or is there only the opposite - the code that's reading the format?

Stefano Zacchiroli

unread,
Apr 23, 2019, 11:47:47 AM4/23/19
to bean...@googlegroups.com
On Tue, Apr 23, 2019 at 08:03:42AM -0700, Alen Šiljak wrote:
> It's sad that something like this could not have been implemented in
> Python and shared as modules so that others can transform their source
> files (or databases) into beancount format.

Have you ever tried using the ledger Python bindings?

If not, please do, then we'll discuss why it's been done this way :-)

--
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 »

Alen Šiljak

unread,
Apr 23, 2019, 5:36:26 PM4/23/19
to Beancount
Hehehe
I usually get excited when I see the term Python Bindings but after a couple of seconds of joy I remember that it probably doesn't work on Windows and I lose the enthusiasm. I would prefer if these things worked on all platforms. However, I still need to see if it works in Docker, in which case I might finally utilizing some of those.

Has anyone managed to install all the dependencies and run the conversion on Android? It would really help if the script was accessible. My data flow is currently: GnuCash -> ledger -> beancount.

Having at least a common library for outputting the beancount file would help but I guess it is not too difficult. There are Python libraries that read GnuCash and MMEx, so it is just a matter of time to write the transformation to beancount directly.
I also need to look into using CSV for data transfer.

Ideally, as mentioned earlier, I wish I could use both beancount and ledger on the same data set or at least keep them in sync.

francois PEGORY

unread,
Apr 24, 2019, 6:43:47 AM4/24/19
to Beancount
Hello there,
I created some time ago two scripts in order to import and export data from mmex to beancount.

I left mmex since they remove the sync with Dropbox .

Nonetheless, I found that mmex has less functionality than the beancount format. For example, a transfer should be always a separate transaction. This is not the case in beancount.
In addition, I didn't understand all the asset management part of mmex.
But if you want I can clean my code and send my GitHub .

Regards


--
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/3b08522f-a02e-44cc-ae54-7efc09a34aed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alen Šiljak

unread,
Apr 24, 2019, 7:03:33 AM4/24/19
to Beancount
Hi, Francois!

Thanks for your feedback. That is interesting news.
As for MMEx, there are reasons for all those decisions and it usually narrows down to limitations in resources (time, developers). In respect to the Android app, Google keeps changing its rules for Play Store, and CloudRail - which was used to communicate with cloud services - dropped its support for storage services.

I'm currently using MMEx on mobile devices and it serves the purpose. The benefit is that I can modify the code and add the features that help me out. Disregard at the moment the data structure, we can leave that as an implementation detail which is irrelevant for exporting the data to beancount.
The asset allocation actually works well but is not documented at all. I've moved the asset allocation code to Python - https://github.com/MisterY/asset-allocation - as it better suits my purpose there and is easier to maintain. Well, it now works and there is no need to adjust it.
On my todo list is a task to try out the Asset Allocation functionality in ledger. I have all the parts for creating just the balance records (to avoid processing) which would be used with the asset allocation definition in a separate file.

I also created a Python lib -https://gitlab.com/alensiljak/moneymanagerexlib - which can read MMEx database (the version which is currently supported by the Android app). This works fine and I used it for CSV generation for GnuCash. I'd assume that all that's needed is the BeanCount format definition, and a mapping for transactions/posting.
I will, actually, move forward with this at some point as I intend to continue using MMEx on the phone but I also need that data in my main application. Whether the functionality ends up in the mobile app or in the Python library that reads the SQLite database directly, I don't know yet. Probably Python, since it can now run on Android, too.

It is unfortunate that you are no longer using MMEx for Android, as additional manpower would be really handy in enhancing any of the parts of the chain.
One thing that would be handy is the transaction definition (i.e. a class) which accepts all the Beancount supported properties, that I could fill out from MMEx entities, and it would give me a string representation back, which I could save into the resulting file.
If you have this part, then please do share it somehow. I have most of the pieces laid out, just need the time to put them together.

Cheers!

Martin Michlmayr

unread,
Apr 24, 2019, 8:29:05 AM4/24/19
to bean...@googlegroups.com
* Alen Šiljak <alen....@gmx.com> [2019-04-23 14:36]:
> Ideally, as mentioned earlier, I wish I could use both beancount and
> ledger on the same data set or at least keep them in sync.

FWIW, beancount's bean-report has a ledger export, but it's fairly
basic at the moment.

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

Alen Šiljak

unread,
Apr 24, 2019, 9:08:41 AM4/24/19
to Beancount
Thank you! That is useful. I might keep track of the tools available in something like this:


Others might find it useful and contribute some recommendations that work well. I should probably keep such notes in a public repo / web site.

I'd assume that bean-report would not be too difficult to add to. I'm also not targeting any fancy features in journal. Just plain postings from/to an account, and trades of commodities. Obviously I'm no fan of system-specific syntax after going through a few of these migrations.

Alen Šiljak

unread,
Apr 24, 2019, 9:10:44 AM4/24/19
to Beancount
Of course, I immediately skipped the one from the title.


I'm aware of the links at plaintextaccounting but have no practical experience with tools other than the ones I put here.

francois PEGORY

unread,
Apr 24, 2019, 11:31:59 AM4/24/19
to Beancount
in term of software to use on android to write my expenses( then sync with beancount), after using mmx, now i use http://www.myexpenses.mobi/en/
i prefer it. (real sync possible, possible to have inside a split transaction a transfer to another account).


Gary Peck

unread,
Apr 25, 2019, 12:38:59 PM4/25/19
to Beancount
On Wednesday, April 24, 2019 at 8:31:59 AM UTC-7, francois PEGORY wrote:
> in term of software to use on android to write my expenses( then sync with beancount), after using mmx, now i use http://www.myexpenses.mobi/en/

That looks quite useful for entering transactions on the go. If you already have a beancount importer configured for the My Expenses export format, do you mind sharing it?

Also, does anyone know of apps for iOS for entering transactions on the go that allow easy export to beancount?

Thanks,
Gary

francois PEGORY

unread,
Apr 25, 2019, 12:44:21 PM4/25/19
to Beancount
Currently not yet but it is a short term project. I will have something in may ...
It seem to be easy but the problem is if I want to sync , I need to add some metadata to beancount. (To have an uuid for each account and transaction)

Regards

--
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.

Martin Blais

unread,
Apr 25, 2019, 2:03:54 PM4/25/19
to Beancount
For export it seems like it can email a csv


francois PEGORY

unread,
Apr 25, 2019, 3:49:19 PM4/25/19
to Beancount
In fact, the sync functionality export JSON 

Alen Šiljak

unread,
Apr 27, 2019, 9:22:54 AM4/27/19
to Beancount
Stefano, quick question on the topic - I'm getting

"Non-standard root name Trading used; please set name_* option"

message in the resulting file. This is because I have a root "Trading:" account for trading accounts, as implemented in GnuCash.
I see no example in the sample yml file to see how to apply this option. What does this refer to? Is it a beancount option or an option for the export script?
Would you mind giving me a syntax example, please? Thanks a lot!

Martin Michlmayr

unread,
Apr 27, 2019, 9:27:11 AM4/27/19
to bean...@googlegroups.com
* Alen Šiljak <alen....@gmx.com> [2019-04-27 06:22]:
> "Non-standard root name Trading used; please set name_* option"
>
> message in the resulting file. This is because I have a root "Trading:"
> account for trading accounts, as implemented in GnuCash.
> I see no example in the sample yml file to see how to apply this option.
> What does this refer to? Is it a beancount option or an option for the
> export script?
> Would you mind giving me a syntax example, please? Thanks a lot!

It's a beancount option, see https://docs.google.com/document/d/1_-T_BvDtUjj9M7liZMNSkrL8pgC60TGMBlYCiV1e4ZM/edit

beancount can only have five account types so you probably want to
rename these accounts. You can use the ledger2beancount account_regex
config to do mass renames.

From the ledger2beancount docs:

Unlike ledger, beancount expects all account names to start with one
of five account types, also known as root names. The default root names
are `Assets`, `Liabilities`, `Equity`, `Expenses`, and `Income`. If you
want to use other root names, you can configure them using the beancount
options `name_assets`, `name_liabilities`, `name_equity`,
`name_expenses`, and `name_income`.

Alen Šiljak

unread,
Apr 27, 2019, 9:34:56 AM4/27/19
to Beancount
Thanks, Martin!

account_regex is the option I'm looking for. Sorry, only now I see this under the Accounts section in the manual. I was searching for name_* option.

From what I remember, the Trading accounts should simply be moved under Equity.

Alen Šiljak

unread,
Apr 27, 2019, 9:41:52 AM4/27/19
to Beancount
Hm, next issue (doch):

I'm using the following definition:

account_regex:
  ^Trading:(.*): Equity:Trading:$1

and it applies correctly for the "open" directive:

1970-01-01 open Equity:Trading:CURRENCY:AUD

while there is extra "Equity" in the journal!

2017-10-06 txn ""
  Assets:Investments:Broker:Cash--EUR-        5.71 EUR @@ 6.71 USD
  Equity:Equity:Trading:CURRENCY:USD                     6.71 USD
  Assets:Investments:Broker:Cash--USD-       -6.71 USD
  Equity:Equity:Trading:CURRENCY:EUR                    -5.71 EUR @@ 6.71 USD

These are then reported as invalid transactions.
Am I doing something wrong?
Cheers

Martin Michlmayr

unread,
Apr 27, 2019, 11:19:01 AM4/27/19
to bean...@googlegroups.com
* Alen Šiljak <alen....@gmx.com> [2019-04-27 06:41]:
> while there is extra "Equity" in the journal!

Hmm, weird. Can you open an issue at https://github.com/zacchiro/ledger2beancount/issues

Just copy this email into the issue system.

Martin Michlmayr

unread,
Apr 27, 2019, 12:00:03 PM4/27/19
to bean...@googlegroups.com
* Martin Michlmayr <t...@cyrius.com> [2019-04-27 22:18]:
> * Alen Šiljak <alen....@gmx.com> [2019-04-27 06:41]:
> > while there is extra "Equity" in the journal!
>
> Hmm, weird. Can you open an issue at https://github.com/zacchiro/ledger2beancount/issues

Thanks for reporting this interesting issue. It's fixed now.
Reply all
Reply to author
Forward
0 new messages