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

5 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

per isakson
per isakson il 10 Giu 2013
  1 Commento
Giorgos Papakonstantinou
Giorgos Papakonstantinou il 10 Giu 2013
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by