Mostrar comentarios más antiguos
Hello, I try to use the following command to read in a csv file
[data D]=importdata('FI.csv',',');
the file looks like
Time last_price volume Security Side 1/3/2011 9:10 100.18 678 RXP1EX GY Equity B 1/3/2011 9:30 100.18 84524 RXP1EX GY Equity B
However, Matlab returns a cell with 1 column only, instead of 5. How can i fix this? Cheers,
Respuestas (2)
Jan
el 6 de Jul. de 2011
You specify in the call of IMPORTDATA, that the values are separated by commas. But the file does not contain commas. Perhaps this works:
[data, D]=importdata('FI.csv', ' ');
john
el 6 de Jul. de 2011
There is a function
csvread(parameters...)
which I've used before for this. Check it out.
2 comentarios
Christof
el 6 de Jul. de 2011
john
el 7 de Jul. de 2011
Ok. Then I'd go with Jan's answer above -
This should give you the line broken up into (many) fields and then you just work with the fields you want.
Have you tried the import wizard and used it to generate m-code? Just double click the data file in Matlab.
Categorías
Más información sobre File Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!