GNOME Bugzilla – Bug 721196
CSV. Cannot import lines with empty fields for deposit or withdrawal in bank transaction download
Last modified: 2018-06-29 23:23:03 UTC
Some CSV files downloaded from banks have empty fields for withdrawal or deposit instead of "0.0". The importer cannot understand lines where this is the case, ie all of them. Empty fields should probably be interpreted as 0.0 .
Created attachment 264994 [details] [review] Sets field to 0.0 when field is empty Only apples for withdrawal, deposit or balance fields.
Comment on attachment 264994 [details] [review] Sets field to 0.0 when field is empty I wonder if this operation doesn't risk memory corruption. Here's my reasoning: - Assuming str is effectively "" - That would mean it only occupies one byte of memory (the \0 termination character) - g_strdup will allocate a new string of one byte long as well for str_dupe. - strcmp detects the zero-length string so - g_stpcpy is called to copy a for byte long string "0.0" into the 1 byte long buffer. That's 3 bytes too much unless g_stpcpy also allocates memory. But I couldn't deduce that from its description [1]. IMO to be on the safe side you should use another g_strdup inside the if clause. Of course that does allocate memory so you need to g_free str_dupe before g_strdup'ing "0.0" into it. [1] https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-stpcpy
Created attachment 269695 [details] [review] Updated patch You're right. New patch.
*** Bug 725846 has been marked as a duplicate of this bug. ***
*** Bug 726145 has been marked as a duplicate of this bug. ***
It would be good to mark the version of GNUCash this refers to - I'm thinking this must be from 2.6.1 isn't it? Would save me reporting a duplicate bug..
Committed patch to master 67d90c9... Please test.
Since there's been no further reports I'll assume all is well and close this bug.
*** Bug 742023 has been marked as a duplicate of this bug. ***
Bug 742023 has been marked a duplicate of this of this bug and reopening this bug and updating the version. Pasted from bug 742023: example csv, Date;Description;in;out 2014-12-05;ATM withdrawal;500,00;; 2014-12-04;Expense;240;; <---no zero amount In this case i have to edit the file and add 0,00, as the importer will fail as it "does not understand the column field "out" or "in", depending on which is blank.
It seems I forgot that some locales use a comma for decimal separator. Pushed to maint branch.
This really needs a regex to ascertain if the field contains a valid numeric value. Committed to maint, 5e60a234006ef
Comment on attachment 269695 [details] [review] Updated patch As far as I can see this patch has been committed to both maint and master. Just marking it as such to remove it from the unreviewed patches list in bugzilla.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=721196. Please update any external references or bookmarks.