Importing QIF files

Derek Atkins warlord at MIT.EDU
Wed Feb 4 09:29:46 EST 2015


Mark Wigmore <mawigmore at gmail.com> writes:

> On 3 February 2015 at 14:59, Derek Atkins <warlord at mit.edu> wrote:
>
>     Not odd at all.
>    
>     QIF doesn't *require* those preambles, but when they get used they are
>     required.  It's like programming a bit:  *IF* you use a variable then
>     you have to define/set that variable.  But if you don't use the variable
>     then it's not required.
>    
>     When you have a single-account QIF file there are no "variables" that
>     get used, so it doesn't have to define them.
>    
>     I'd still love to see the QIF file that breaks the importer; the
>     importer is fairly well tested and QIF really hasn't changed much.
>
> OIC. As much as I'd like to send you the QIF file I trust you'll understand why
> I can't... It's a shame the error messages don't give more clues as to what's
> wrong.

It depends on the error message.  Often it does, but it doesn't (and
cannot) give context.  The reason is due to the way the importer is
implemented.  It first parses the file into its constituent parts.  This
step is the only place where it can give you line-number context.
Unfortunately because QIF is such a free-form "protocol" all it could
tell you is, e.g., it found an unknown !Type at line number X, or it
found an unknown marker at line Y.

By the time it's parsing the contents semantically it's too late -- that
happens in another pass and by that time there is no line number context
available.

Rearchitecting the importer to fix this would, effectively, require
rewriting the whole thing.

For the relatively few times this becomes an issue it's just not really
worth the time and effort.  Usually the error messages (you've looked at
the trace file, too, to see if there's anything more there, right???)
provides enough context to point to the issue if someone actually looks
at the QIF file.

I understand you're unwilling to do that, but honestly, it's not that
hard to do something like:

grep '^N$' file.qif

to look for lines that start with 'N' and have no other data (although
this regex doesn't find lines with only whitespace).  Similarly, one
could look for T lines that don't start with valid number formats:

egrep '^T[^-0-9]' file.qif

Also, responding to another email of yours, comparing QIF and the QIF
Importer to a compiler is not really a good analogy.  A better analogy
would be likening it to loading a DOC file into LibreOffice.  Most of
the time it works just fine, but when it doesn't there's nothing to give
you an idea about what failed.  The difference is that with QIF the file
is a text format and you can often do a little legwork to figure it out.

As for whether or not you use GnuCash in the end, that is obvioiusly
your perogative.  This is a volunteer project with volunteer helpers, so
you get what you pay for.  :)

> Mark

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the gnucash-user mailing list