Use GnuCash Python Bindings to Write Data into GnuCash Files

By Yong-Siang Shih / Tue 24 January 2023 / In categories Projects



I have been using GnuCash to track my finance. However, I often need to manually enter a lot of transactions. To speed up the process, I’ve investigated how to use GnuCash Python bindings to insert a lot of transactions. I use GnuCash example scripts as an example and wrote a simple gnucash-importer.

GnuCash Importer

gnucash-importer can read transactions with CSV format and write the data into GnuCash files.

For example, you we have this CSV file:

09/24/2020,Purchase VTI,CURRENCY::USD,,Assets:Current Assets:Cash Account:TD Ameritrade,,-2500.00
09/07/2020,BND Dividend,CURRENCY::USD,,Assets:Current Assets:Cash Account:TD Ameritrade,,70.00
,,,,Income:Dividend Income:Dividend Income USD:BND Dividend,,-100.00
,,,W-8 Tax Withholding - BND,Expenses:Taxes:Federal:Taxes Withholding:Taxes Withholding USD:2020 Taxes Withholding USD,,30.00

We could use gnucash-importer to insert the transactions:

python -m gnucash_importer target.gnucash source.csv
Yong-Siang Shih


Yong-Siang Shih

Software Engineer, Machine Learning Scientist, Open Source Enthusiast. Worked at Appier building machine learning systems, and interned at Google, IBM, and Microsoft as software engineering intern. Love to learn and build things.* Follow me on GitHub

Load Disqus Comments