I have a series of csv files I'm expecting to receive on a regular basis, and there are two problems with these files.
- I am not guaranteed to have headers.
- I cannot rely on how many data entries there will be per row (sometimes there may be 50 or so, sometimes more)
What I am guaranteed is that, let's say, the 1st, 10th, and 30th column have the data I want. Up until now I've been using a perl script to collapse these csv files to something where the rows have only the elements I'm interested in.
Is there a way in datatool to tell it to create headers for certain columns and ignore the rest?
For example, it would be nice to be able to do something like the following:
\DTLloaddb[noheader,headers={modelname=1,serialnumber=10,weight=30}]{itemweights}{somefile.csv}
which would mean that modelname is in the first column, serialnumber is in the 10th column and weight is in column 30.
Here is an extremely simplified example of a csv file I might work with.
"toaster", "", "", "", "234-02015-23-948", "", "", "", "", "", "1255", "", ""
"blender", "junk", "", "", "753-20842-46-824", "", "", "junk", "", "", "1567", ""
"microwave", "", "", "stuff", "376-73178-68-487", "", "", "", "junk", "", "2434", "", "", ""
"radio", "", "stuff", "junk", "724-86499-61-446", "", "", "", "junk", "", "2343"
"tv", "", "", "", "423-90219-60-149", "", "junk", "", "", "", "3023", "", "", ""
A solution that creates a header for every column is completely infeasible because I have upwards of 50 columns only 3 or 4 of which I'm interested in.
What I'd like to be able to do is write:
\DTLloaddb[noheader,headers={appliance=1,serialnumber=5,detailnumber=11}]{itemweights}{somefile.csv}

datatooldoesn't turn out to be feasiblepgfplotstablecan be an alternative which can handle this. – percusse Jan 21 '13 at 16:35datatoolin such examples, if I telldatatoolthere is a header, it complains about duplicate header names. – A.Ellett Jan 21 '13 at 16:51noheaderand then deal with the first row manually, plus ignore columns. – Alan Munn Jan 21 '13 at 16:54pgfplotstable. I hadn't known about it. I'm a bit reticent to use it because I continually find the various documentation forpgfstuff frustrating: I find I often have to read huge sections of the documentation to get the information I need. My job doesn't allow me the luxury of reading a manual cover to cover to learn some very cool tricks. I like what thepgfstuff can do, but the cost (cost of time) to do something simple is often immense. – A.Ellett Jan 21 '13 at 17:03noheaderin the\DTLloaddb. – A.Ellett Jan 21 '13 at 17:06