With the price of everything going up I felt like I needed to start tracking what I spend money on a bit better, so I looked for some open source software which would help me do that. The best looking one for me was HomeBank. After manually entering transactions for a couple of weeks I decided I should really look at importing the data from the bank rather than retyping it. For my banks current account that was fine, since they let me export data in OFX format which HomeBank likes. My credit card company, Pulse, only allows export as CSV though. HomeBank does have a CSV import option but only if the columns are exactly how it expects them - there is no way to map fields within the program.
So I would either have to convert my CSV file into a different CSV file, or an OFX file. I decided to convert it to OFX by using csv2ofx which I installed using pip. The columns in the Pulse CSV file are Date, Description, Amount(GBP), so it was easy enough to copy one of the existing csv2ofx mappings and create my own. I did need to add an extra function to convert the date to the format expected by csv2ofx which seems to be American format - although it sometimes worked without modifying the date so I am a bit confused about that bit (as was someone else who found the same problem :) ).
The final pulsemap.py looked like:

from operator import itemgetter

def fixdate(ds):
    dmy = ds.split("/")
    # BUG (!?): don't understand but stolen from ubs-ch-fr.py
    return ".".join((dmy[1], dmy[0], dmy[2]))

mapping = {
    "has_header": True,
    "bank": "Pulse",
    "currency": "GBP",
    "delimiter": ",",
    "account": "Pulse",
    "date": lambda tr: fixdate(tr["Date"]),
    "amount": itemgetter("Amount(GBP)"),
    "desc": itemgetter("Description"),
}

and to use it I just need the command

csv2ofx -x pulsemap.py recentTransactions.csv pulse.ofx

update: Instead of using the fixdate function in the map, I think I could have passed the -y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day option to csv2ofx

The resulting OFX file can then be imported into HomeBank. Since the credit card company provides the total of each transaction every amount is positive, so on the HomeBank import screen I also need to tick the Toggle amount option so it is debited from my balance instead of added to it.
Once imported I just needed to go through each new transaction and set the category.

Previous Post Next Post