Read data from CSV files

Hi,
I would like to read data from a CSV file between column A and column K such that those columns contains numbers only. In that file, column L is not number but alphabets. When I use the function "csvread" it gives the following error message:
Mismatch between file and format string. Trouble reading number from file (row 1, field 12) ==> F, 0
I am wondering how can I read the data from that CSV file?
By the way, I am using Matlab R2006a.
Thanks,
Alan

댓글 수: 2

Chirag Gupta
Chirag Gupta 2011년 4월 29일
http://www.mathworks.com/matlabcentral/answers/4840-read-csv
Alan Leung
Alan Leung 2011년 4월 29일
I specify the column range (column A to column K), but it still gives the error.
I have 150+ CSV files, so I have to change those files one by one, even though I have Matlab!?

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

답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 4월 29일

0 개 추천

Try using textscan to read your data.
Typical usage:
fid = fopen(filename,'w');
data = textscan(fid,'%g %g %g %g %g %g %g %g %g %g %g %*s','delimiter',',');
fclose(fid);

댓글 수: 1

Alan Leung
Alan Leung 2011년 4월 29일
The data that I want to read start from row 3 as the format of row 1 and row 2 is different. Please advice how I can skip row 1 and 2.

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

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

질문:

2011년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by