Hello, I have the following .csv file and I want to read only -0.192 and -0.168 from the third and the fourth line and ignore rest:
"Record Length",1000000,"Points"
"Trigger Time",0,s
,,,-9.99988E-06,-0.192
,,,-9.99986E-06,-0.168
I am using the following code to remove the header in the first two lines:
fid = fopen('wave00000001.csv','r');
datacell = textscan(fid, '%f64', 'HeaderLines', 2);
prbs = cell2mat(datacell);
fclose(fid);
How can I remove the ,,,-9.99E-06 values from the 3rd and the 4th line.
Thanks and Cheers, Ahmad

 채택된 답변

per isakson
per isakson 2014년 10월 13일
편집: per isakson 2014년 10월 13일

0 개 추천

Replace
'%f64'
by
'%*f%*f%*f%f%f'
"64" is by default

댓글 수: 3

per isakson
per isakson 2014년 10월 14일
편집: per isakson 2014년 10월 14일
Thanks Per Isakson. It works :) However I have to change the %*f to %*c.
I have quite big data file to read. It is 1000000x1 matrix. However, I can only get the first 23,000 values (e.g. 23000x1). How can a large data file be read using textscan.
Thanks
(move from separate answer to comment by per isakson. @Almad, please delete the empty answer. I'm not allowed.)
per isakson
per isakson 2014년 10월 14일
  • "I can only get the first 23,000 values" &nbsp And there are no error or warning(?). I'm pretty sure there is something in line 23000/2+1, which does not match the format specifier.
  • " change the %*f to %*c" &nbsp That's strange, I actually tested and work for me with %*f. Nevermind.
Ahmad Mustafa
Ahmad Mustafa 2014년 10월 22일
Great. It works. Many thanks for your help :)
Cheers, Ahmad

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2014년 10월 13일

댓글:

2014년 10월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by