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

 采纳的回答

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

3 个评论

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

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by