필터 지우기
필터 지우기

dataload

조회 수: 1 (최근 30일)
Christof
Christof 2011년 7월 6일
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,
  댓글 수: 2
Christof
Christof 2011년 7월 6일
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
Jan
Jan 2011년 7월 6일
Please edit your original post. I assume it gets nicer if you start the lines showing your file by a space.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2011년 7월 6일
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
john 2011년 7월 6일
There is a function
csvread(parameters...)
which I've used before for this. Check it out.
  댓글 수: 2
Christof
Christof 2011년 7월 6일
when I use that command, Matlab spits out an error
Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 1) ==> Time,
Error in ==> csvread at 52
m=dlmread(filename, ',', r, c);
think it does not like strings, only integers
john
john 2011년 7월 7일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by