Problem
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:
date,description,commodity,memo,account,amount,value
09/24/2020,Purchase VTI,CURRENCY::USD,,Assets:Current Assets:Cash Account:TD Ameritrade,,-2500.00
,,,,Assets:Investments:Stock:VTI,10,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
,,,,Assets:Investments:Bond:BND,,
,,,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