Loading csv file with increasing columns into matrix
silvan.roth
Hi,
I have the csv file below. It starts with a header of two columns for about 30 lines, and then comes data with about 10 columns width.
Eventhough I force the load to a width of 10 columns, it only reads the width og the header till the end of the file
LoadWave/J/M/D/N=dummy/O/E=1/K=2/V={"\t"," $",0,0}/L={0,0,0,0,10}
How can I load the complete file?
Cheers
Silvan
Since the file has different sections with different shapes, you have to load one section at a time. For example, this loads the data from line 30 (zero-based) to line 58 and from column 1 to 16:
LoadWave/J/M/D/N=dummy/O/E=1/K=2/V={"\t"," $",0,0}/L={30,31,28,1,15}
This loads the data into a text matrix wave because the data is a mix of text and numeric. That is probably not what you want. The correct way to load a given section depends on what you want to do with the data in that section.
The addition of /K=1 forces LoadWave to treat the data as numeric. This creates a numeric matrix wave with column 0 blank because it contains text:
LoadWave/J/M/D/N=dummy/O/E=1/K=2/V={"\t"," $",0,0}/L={30,31,28,1,15}/K=1/P=Roth
Changing 15 (number of columns) to 11 loads 11 columns from column 1 (zero-based) to column 11:
LoadWave/J/M/D/N=dummy/O/E=1/K=2/V={"\t"," $",0,0}/L={30,31,28,1,11}
December 21, 2021 at 04:36 am - Permalink