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

5 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

per isakson
per isakson el 10 de Jun. de 2013
  1 comentario
Giorgos Papakonstantinou
Giorgos Papakonstantinou el 10 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by