New Python QIF import script.

kim.aldis's Avatar


24 Apr, 2013 11:20 AM

The thin-ness of documentation and examples meant I had to put a fair bit of work into getting this script up and running so I thought I'd drop it here by way of example. If it saves someone else some work then great. if not, well, it saves me work so that's OK.

With the usual caveats about it not being my fault if it eats your dog or kills your children, consider it open source, do with it as you see fit. Suggestions gratefully received. If you Infinite Kind guys want to use it in your examples lib please feel free.

It imports transactions from QIF files. It came about because I've always had trouble with QIF import from my bank still inserting transactions even though they already exist. Infinite Kind have been very helpful but I think there's something about the way I do things that messes it up so I wrote this script. It flags a match using a brain dead payee/date/amount check and it'll probably only work well if you only ever import your transactions directly from the qif, which is what I do.

The QIF parsing is also fairly simple minded, it only grocks P, D and T tokens and ignores everything else. It should be easy to adapt if you have other needs.

It scans a directory (importDir, hardcoded) and imports from any QIF files it finds there. You'll need the Python extension to make it work.

The biggest stumbling block was working out that what's called a category in the interface is actually called an account in the API. That had me going for a while. I don't think it's written anywhere in the docs.

The other was working out what module I needed in order to call MD class methods, that also had me going for a while. It's 'from import *' .

I really like that MD can be scripted. It's getting me out of some scrapes and saving me time in the long run. It would be nice if the documentation was a little more helfpull but otherwise it works very well.

  1. 1 Posted by Scott Meehan on 24 Apr, 2013 11:18 PM

    Scott Meehan's Avatar

    Hi Kim,

    Thanks for sharing your script! I hope that other users will find it useful.

    Please let us know if we can be of any assistance!

    Scott Meehan
    Moneydance Support

  2. 2 Posted by kim.aldis on 26 Apr, 2013 07:35 AM

    kim.aldis's Avatar

    I should point out, the script expects dates format in the QIF file to be MM-DD-YY. My own bank offers Quicken 1997 (MM-DD-YY) or 2003 ( DD-MM-YY) and I picked 1997. I've no idea if this is standard or not and as far as I can tell there's no way to detect which is which in some cases ( 01-01-13, for example). It would explain, though, why Moneydance gets so upset unless I import Quicken 2002.

  3. 3 Posted by Scott Meehan on 26 Apr, 2013 03:01 PM

    Scott Meehan's Avatar

    Hi Kim,

    If you were having difficulties with importing the QIF file due to being a different date format, did you try changing the Date Format drop down menu when trying to import a QIF file by going to File -> Import?

    Scott Meehan
    Moneydance Support

  4. 4 Posted by kim.aldis on 26 Apr, 2013 03:33 PM

    kim.aldis's Avatar

    Hi Scott,

    No but until I wrote this script I hadn't worked out that this was the problem. I think I might have mentioned it to one of your support staff a while back but because it worked using a 2002 version file I didn't bother following it up.

    I've a feeling this might be a problem at my bank's end. I could be wrong but I wouldn't have thought a Quicken version change would include a date format change of this type. But then I'm equally surprised there's no header flag in the file either. But then I'm not that familiar with the Quicken format so I could be mistaken.

    I've attached another version of the script. An error crept in just before I zipped the first one.

  5. 5 Posted by jeroen.bruijnin... on 20 Mar, 2014 11:02 AM

    jeroen.bruijning's Avatar

    I found that the "other transaction" aka the split does not balance with the parent transaction. After I replaced the line

            split = SplitTxn( newTns, -tIn.Amount, 0, 1.0, acct2, "", -1, ParentTxn.STATUS_RECONCILING )


            split = SplitTxn( newTns, -tIn.Amount, -tIn.Amount, 1.0, acct2, "", -1, ParentTxn.STATUS_RECONCILING )

    the accounts did balance.

    Did I miss something or is this indeed how it should be done?

  6. 6 Posted by Michael on 02 Sep, 2014 11:53 AM

    Michael's Avatar

    Dear all, did Jeroen's solution solve it?

    I have the issue that imported transactions show the right amount in the account they are assigned to. However when opening the category, the amount is 0!


  7. 7 Posted by jeroen.bruijnin... on 06 Sep, 2014 10:53 AM

    jeroen.bruijning's Avatar

    Hi Michael,

    with me the categories are filled with the correct amounts, as far as I can tell. I tried this by adding a category to the sidebar and looking at the details, which were all there.
    Are you viewing the categories in some other way? Or did you change the sample code?

    Regards, Jeroen.

  8. System closed this discussion on 31 Mar, 2015 03:58 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac