Converting CSV files to QIF

tags = []

Recently I’ve started using GnuCash for my personal finances. Eventually I got it running well, after I recompiled it myself, because the version in Debian was segfaulting on start-up (it is also very outdated).

My bank, PostBank only supports exporting transactions in it’s own custom CSV files which, of course, aren’t supported by Gnucash. I wrote a simple Python script that converts PostBank CSV files to QIF, which Gnucash can handle ok.

I’m publishing the script here for others interested in importing PostBank CSV files in their finance apps:

# Very simple converter from PostBank .csv files to
# QIF files for use by (among others) gnucash.
# Written by Jelmer Vernooij <>, 2007

import csv, sys

rows = csv.reader(sys.stdin)

header =

assert header == (['Datum', 'Naam / Omschrijving', 'Rekening']
    + ['Tegenrekening', 'Code', 'Af Bij', 'Bedrag (EUR)']
    + ['MutatieSoort', 'Mededelingen'])

print '!Type:Bank\n'

for l in rows:
    if "-" in l[0]:
        p = l[0].split("-")
        print "D%s/%s/%s" % (p[1], p[0], p[2])
        print 'D%s/%s/%s' % (l[0][4:6], l[0][6:8], l[0][0:4]) # date
    if l[5] == 'Bij':
        print 'T%s' % l[6] # amount
    elif l[5] == 'Af':
        print 'T-%s' % l[6] # amount
        raise Error("Unknown field value '%s'" % l[5])
    print 'P%s' % l[1] # payee / description
    print 'M%s' % l[8] # comment
    print 'L%s' % l[7]
    print '^\n' # end transaction
Go Top