I'm working on some MATLAB code that parses a .csv file into a table. The CVS file has seven columns separated by commas and also contains thousands of rows.
Right now the parsing code looks like this:
fid = fopen('data.csv', 'r');
parsed = textscan(fid, '%s %f %f %f %f %f %f', 'Delimiter',',', 'HeaderLines', 1);
But disp(parsed);
returns an object that contains an array that has only one column. This data looks something like this:
[209,1] = 3/8/2015 16:12:00
[210,1] = 8.09
[211,1] = 952
[212,1] = 603
[213,1] = 100.8
[214,1] = 20.8
[215,1] = 11.3
[216,1] = 10.66
[217,1] = 3/8/2015 16:47:00
[218,1] = 8.1
[219,1] = 950
[220,1] = 604
[221,1] = 100
[222,1] = 15.8
[223,1] = 11.18
[224,1] = 10.71
[225,1] = 3/8/2015 17:22:00
[226,1] = 8.07
[227,1] = 981
How do I break this data up into a table. I want to be able to interface by data like: parsed[1][3]
. I think I'm just missing an obvious parameter to pass into the textscan()
function, but I can't find any documentation on this anywhere.
Any help you could provide would be greatly appreciated!
Update:
Here's a small sample of the CSV file I am working with:
dt,temp,ldo,turbidity,ldo.per,orp,conductivity,ph
3/8/2015 00:02:00,7.99,11.52,3.8,96.3,612,1038,8.01
3/8/2015 00:07:00,7.98,11.52,3.5,96.3,612,1038,8.01
3/8/2015 00:12:00,7.96,11.52,3.4,96.3,612,1038,8.01
3/8/2015 00:17:00,7.97,11.54,3.7,96.5,612,1038,8.01
I'd like the output to look something like:
A =
3/8/2015 00:02:00 7.99 11.52 3.8 96.3 612 1038 8.01
3/8/2015 00:07:00 7.98 11.52 3.5 96.3 612 1038 8.01
3/8/2015 00:12:00 7.96 11.52 3.4 96.3 612 1038 8.01
3/8/2015 00:17:00 7.97 11.54 3.7 96.5 612 1038 8.01