Personal Finance & Money Stack Exchange is a question and answer site for people who want to be financially literate. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a script that cleans up OFX transaction files downloaded from banks so that the name and memo fields are more readable once imported into gnucash. This works great, I now get very clean records that include only the information I need for each transaction. The problem is, even after the clean up, gnucash's bayesian matching makes a lot of mistakes in matching transactions to accounts, and frequently "forgets" matchings it knew in the past.

I was wondering if there is anything else I can do to the OFX files in my cleanup script to give gnucash better hints as to what account a given transaction should go. I would like to bypass the bayesian matching stuff completely, and instead insert an explicit account name for each transaction in the OFX file. Looking through the OFX spec I could not find any fields for this. Is this possible at all?

If I could do that, then my script can assign default accounts for the common transactions that show up over and over again, like groceries, gas, etc. Then I'll have only the exceptions to handle manually.


share|improve this question
Did you get an answer to your question ? I have the same interrogation and need! I'm used to MsMoney transaction matcher, and even if it's not perfect, it seems better than GnuCash's one. Maybe I've missed an important setting in GnuCash... Someone has an hint for us ? Thanks a lot! – user5433 Jan 4 '12 at 15:59
@Pat: I did not find a satisfactory solution to this problem. I'm still using the bayesian matching, with its limitations it is still the best option for gnucash. – Miguel Jan 7 '12 at 22:41
Could you share your script? Gist.github or pastie or anything that is ok for you! – f1StudentInUS Apr 19 '12 at 5:39
I wrote a tool here that tags transactions depending on payee field content, and GnuCash uses that tag as destination account ... but as of today it handles only qif files. I second @Patches idea to put account name in the memo field, and if it works maybe you should consider then put the business name elsewhere? – kraymer Mar 22 '15 at 22:18

You can generate the transactions directly into your GnuCash XML file via the GnuCash python bindings. You could probably alter your script to directly generate the XML for the transactions into your GnuCash database in this manner. You would then open GnuCash and everything would already be there. See a simple example which creates some accounts and transactions, and the docs for the python bindings.

share|improve this answer

You can turn off bayesian matching, so you can bypass it like you want to do without messing with the import file.

Go to Edit->Preferances, Online Banking tab, uncheck "Use bayesian matching"

From the gnucash documentation, about half way down this page:

share|improve this answer
I don't think this solves the problem. I do not want to have to manually match every transaction to the proper account. If I disable the bayesian matching won't I have to assign accounts to every transaction? What I really want to do is to insert the accounts in the OFX, it would be very easy for me to do that in the script that I use to clean the OFX files I download from my banks. – Miguel Jan 7 '12 at 22:38
@Miguel hmm... after re-reading your question, I guess you're calling transaction categories "accounts"? Try inserting the category keyword into the memo field and let the bayesian matching do it's thing. In other words, add "groceries" onto the memo to help it show up in the "groceries" account. – Patches Jan 8 '12 at 4:51
In gnucash there are only accounts, there are no categories. The problem with rewriting the Memo field is that I use it to store the business name. Even if I used the memo, this does not solve the problem that every once in a while the bayesian database gets very confused and most of the mappings are lost and need to be redone. – Miguel Jan 8 '12 at 5:41
@Miguel Well, I only got two more ideas: one, look into the payee model of ofx - section 12.2 of the ofx documentation, IIRC. The other is buy quicken, lol – Patches Jan 8 '12 at 14:38

It looks like you're right, in that the OFX spec doesn't support what you're trying to do, which means that GnuCash probably won't support it.

As a last option, you could build a GnuCash plugin to to this (, but it doesn't seem like a very easy architecture to get into.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.