4

I am using GnuCash 2.6.7 under Mac OS X 10.10.4 to do my personal finance. I have a fairly large account structure by now with many expense accounts to track different categories of spending.

I would like to use ledger, or preferably hledger, to work on that data which I have created with GnuCash.

Is there a way to import my accounts, transactions etc into (h)ledger? What is the most painless/recommended way to do it?

Simon Michael
  • 366
  • 1
  • 10

1 Answers1

10

Answering my own question, I figured it out: yes, there is a way, with a tool called gnucash2ledger.py.

  • First, save the GnuCash book in sqlite3 format with "Save As..." (if you have an older version of GnuCash, make sure the appropriate database backend is installed).
  • Use this command line tool to convert the sqlite3 books into ledger plain text format: https://github.com/MatzeB/pygnucash
  • For example, if you saved the books in sqlite3 format from within GnuCash as foobar.sqlite3, you can convert it to ledger format like this: python2 gnucash2ledger.py foobar.sqlite3 > foobar.txt
  • Note, this ASCII file will contain the account structure and the actual transactions. With the versions I could use for testing, this leads to errors. I removed the account structure leaving only the actual transaction entries (blocks starting with a date).
  • For hledger, you might need to convert it additionally like this: ledger -f foobar.txt print > foobar.journal

Versions used: GnuCash 2.6.1, Ledger 2.6.2, hledger 0.22