Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: help reading csv file with string
Posted:
Dec 16, 2010 6:33 AM
|
|
Walter Roberson <roberson@hushmail.com> wrote in message <f_jNo.4451$My1.4090@newsfe16.iad>... > On 13/12/10 1:16 AM, Anonymous wrote: > > Hi, im not really good at Matlab so please bear with me, here's my > > problem: I have a csv file that contains a plenty of row data like this > > > > 1,10/9/2010 > > 05:42:59:390,0.25873534,0,0.25053943,0,0.26066645,0,0.26313331,0,0.6127435,0,0.015781,0,0.016664,0,0.016033,0,0.016664,0 > > > > > > I would like to read the data in matlab and transform it into a matrix. > > But matlab only reads csv files with pure numeric or text, how can i > > remove the string section? What commands should i use? Thanks > > I advise using textscan() with a 'Delimiter' of ',' and 'Whitespace' set > to '' so that the space between the date and time is not treated as > ending that particular cell. Use %f as the format for floating point > numbers (or integers that you want to store as double precision), use %s > for the date and time. It appears to me that an appropriate format would > be ['%f%s', repmat('%f',1,18)]
I tried using the disp function and it was able to display the csv file. Can i add specific columns in the array done by the disp function into another array? Thanks. Really need your help
|
|
|
Date
|
Subject
|
Author
|
|
12/13/10
|
|
Guest
|
|
4/2/12
|
|
Walter Roberson
|
|
4/2/12
|
|
Guest
|
|
4/2/12
|
|
Guest
|
|
|