CSV Import Update

Benjamin Sperisen lasindi at gmail.com
Mon Jul 16 01:16:52 EDT 2007

Hi Josh and Christian,

I thought I'd just write a summary of the status of the CSV import
code, and what still needs to be done.

What can the importer do now?
1. It can handle different encodings.
2. It can handle different separators and various date formats.
3. It is date-separator agnostic. (This is using the regex recommended
by Derek : https://lists.gnucash.org/pipermail/gnucash-devel/2007-July/020948.html)
4. It can handle three different column types: Amount, Date, and
Description. The columns can be in any order.
5. If there is an error with any of the rows, it will interpret the
rows that do not have errors, and then let the user try changing the
configuration to parse the remaining rows.

What shortcomings does the importer have?
1. When errors do occur, the user is not informed of what they are,
just which rows have them.
2. There is not yet any support for fixed-width files.
3. The column type selection interface is somewhat clumsy. You have to
click on the column to select the row, and then click, hold and move
to select a new type. I don't think this is particularly obvious, but
this is the best I can think of with stock GTK+ widgets.
4. It has not undergone extensive testing.
5. This is not necessarily a CSV import issue, but the date parsing
function does not yet take into account the issue raised by Thomas
(It is also hiding as a static function in one of my source files, but
it could easily be moved.)

Problems 1 and 2 are just a matter of coding, and I know at least
roughly how to attack them.

Problem 3 is a bit trickier. I'm thinking it could be slightly
improved by automatically selecting the treeview row when the dialog
is shown, but I'm wondering if there is a more elegant interface for
this sort of thing. I did a lot of experimentation with an hbox of
comboboxes that would resize automatically by doing size requests (to
align themselves with the treeview below), but that didn't work very
well, since when I expanded the window, I couldn't shrink back.

Problem 4 will largely take time, but if anyone has any CSV files that
they'd like to try this with, feel free -- the code should be stable
enough that it's not totally unusable at this point. As long as you
don't try to use a fixed-width file, you should be able to import your
CSV file (and if it doesn't work, any feedback on that is definitely
welcome!). I've also committed an example file in my branch at

Finally, I'm thinking I can solve problem 5 by maybe adding a boolean
argument to the function to specify that the string should be parsed
as QIF date string (to take into account apostrophes). I feel fairly
safe ignoring apostrophes in CSV land, just because I've never
encountered that before (though I could be wrong). I'll also have to
learn some about regular expressions, as I know next to nothing about
them, to add the functionality.

Anyway, that's where the code is and where it still needs to go. As
always, let me know if you have any comments or suggestions!


More information about the gnucash-devel mailing list