Textscan with repeated header lines. Remove the repeated header lines.

5 次查看(过去 30 天)
I want to extract the values of csv file. The csv files contains repeated headers. Example:
\n
Scan Parameters
\n
Scan Type,Standard Scan
ID,700
Stylus,Radius: 12.5 µm
Length,600.0 um
Duration,30 sec
Resolution,0.067 um/sample
Force,1.00 mg
Measurement Range,524 um
Profile,Hills
\n
\n
Scan Data
\n
Horizontal Distance,Raw Data,
um,A,
0.0,0.0,,
0.1,15.8,,
0.1,15.8,,
0.2,6.8,,
0.3,0.5,,
.......................................
599.8,23.9,,
599.9,30.4,,
599.9,30.2,
\n
Scan Parameters <------- this is the first line of the 2nd set of headerlines
There is a repeated set of headlines in the data file. The first of headlines is 18. Then there is a newline and then follows another set of repeated headlines. I would like to remove all this headers and extract only the values.
For only one set of headerlines I do this and I extract all the values. after the headerlines. I haven't managed to do it with multiple headerlines.
textscan(fid(i), '%f %f','delimiter',',','HeaderLines',18,'MultipleDelimsAsOne',1)

采纳的回答

per isakson
per isakson 2013-6-10
  1 个评论
Giorgos Papakonstantinou
Honestly Per I cannot make it work. And this is because I am trying to read multiple csv files at once. When I have multiple csv files having only one set of header lines each this command is sufficient.
textscan(fid(i), '%f %f','delimiter',',','HeaderLines',18,'MultipleDelimsAsOne',1)
I had a for loop and for every csv file and it was ok.
Now with the method that you propose here I cannot make it work on one csv file which contains many sets of header lines.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by