GnuCash Python helper script to import transactions from QIF text files into GnuCash .gnucash sqlite file (or into PostgreSQL/MySQL).
Main use case for myself was automating the import of QIF files generated by GnuCash Mobile Android app into my desktop GnuCash application.
It's a fork of Gnucash QIF Import, but uses piechart instead of Gnucash python bindings.
NOTE: this package doesn't work with standard XML gnucash files. You can convert your XML file to sqlite simply using GnuCash's "save as..." command.
- Python 2.6+
- GnuCash book stored in SQLite, PostgreSQL or MySQL format
- MTP tools (optional, to import from MTP device)
For sqlite GnuCash files:
qif2gnucash -v -f examples/accounts.gnucash examples/expenses.qif
For GnuCash books stored in MySQL or PostgreSQL:
qif2gnucash -v -f mysql://$USERNAME:$PASSWORD@$HOSTNAME/accounts examples/expenses.qif
The above command should log two "Adding transaction for account.." lines and will add the expenses from examples/expenses.qif to the accounts.gnucash file. Open accounts.gnucash (or the equivalent database in case of MySQL) with GnuCash before and after executing the above command line to see the difference.
The Python script will assume "EUR" as default currency (QIF files do not specify any currency). Use the --currency
command line flag to change this.
The import.py script also supports directly importing QIF files from devices supporting MTP, e.g. Android phones. This is handy if you use GnuCash Mobile and want to synchronize (importing previously saved QIF files) when connecting your phone via USB. You need the "mtp-tools" command line programs to use this feature:
sudo apt-get install mtp-tools
To import all files ending with ".qif" from your MTP device (connected via USB) into your "my-accounts" GnuCash file:
qif2gnucash -v -f ~/my-accounts.gnucash mtp:.*.qif
You can use the --dry-run
option to do a safe trial run.
In order to be able to safely repeat the above command without getting a bunch of duplicate transactions (and to speed up the stupidly slow MTP access),
the import.py script remembers the imported file names in ~/.gnucash-qif-import-cache.json
.