Textscan to choose the specific text
1 view (last 30 days)
Show older comments
Ahmad Mustafa
on 13 Oct 2014
Commented: Ahmad Mustafa
on 22 Oct 2014
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
0 Comments
Accepted Answer
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
on 14 Oct 2014
- "I can only get the first 23,000 values"   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"   That's strange, I actually tested and work for me with %*f. Nevermind.
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!