trouble with date when importing a just exported csv file.

Mike or Penny Novack stepbystepfarm at mtdata.com
Fri Jan 30 08:44:13 EST 2015


>
>> Probably the fastest way to get something working would be to write a
>> program to translate from the CSV format that your brokerage provides 
>> into
>> QIF or something else for easier importing into GnuCash.
I think that there might be some slight confusion (at least uncertainty) 
about where the real problem lies.

CSV is a data FORMAT. All csv means is a sequence of data items 
separated by commas ("csv stands for comma separated variables). What 
each data item IS depends on its position. There are usually no field 
identifiers as there would be in a data format that used "keywords" to 
identify the fields. A data file in csv format COULD logically be 
"keyword" data instead of "positional" data if every other field in the 
data were the field identifier but this is rarely the case.

That means that a csv file can't necessarily be used without reordering 
the fields in the logical sense. In other words, the import process has 
to interpret which field is which, either by providing a way to specify 
that OR having the file actually reordered first. Converting the csv 
file to a qif file has to do that too.

The USUAL problem is a mistake in specifying which filed is which (what 
is the field order). You have no reason to suppose that a csv file 
coming from some other source will be having the same field order as you 
need just because it is in the csv format.

A hint for those who want to try editing such files (I used to do this 
sort of thing for my living). FIRST do an export of known data and then 
test this by importing. If you got the same result, then the export to 
import is correct. Now with a suitable editor LOOK at that export and 
identify all the fields. You second step is to look at the csv file you 
propose to import. Identify all the fields playing close attention to 
how the filed order differs from what you had in the first step. OK, if 
your import function provides "mapping"you can now try to get that 
right, first importing into a test file because you are bound to make 
some mistakes. If your import function doesn't have a mapping facility 
you write a batch editing program (or script) to do the job, again first 
trying the result importing to a test file till you have that editing 
process right.

I am NOT going to suggest viewers/editors for looking at the files 
except to point out that in the worst case scenario a "hex editor" can 
look at anything (even the machine code of a program). Those of you 
running a 'nix will of course have enough batch editing power to reorder 
a csv file with your shell language plus standard utilities. But please 
do note that this is really "programming" and if you don't have prior 
experience programming allow plenty of time for the learning curve and 
testing (and correcting) your work.

Michael D Novack, FLMI


More information about the gnucash-user mailing list