Textscan to choose the specific text

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

 Accepted Answer

per isakson
per isakson on 13 Oct 2014
Edited: per isakson on 13 Oct 2014
Replace
'%f64'
by
'%*f%*f%*f%f%f'
"64" is by default

3 Comments

per isakson
per isakson on 14 Oct 2014
Edited: per isakson on 14 Oct 2014
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.)
  • "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.
Great. It works. Many thanks for your help :)
Cheers, Ahmad

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!