Textscan to import a csv file with random amount of rows and blank rows

I want to import a file using textscan or any method that looks like this [ Devices 200 John Collette FRAME,SUB FRAME,1V,2V,3V,4V,5V 1,1,.343,.234,.233,3.23,.233 2,1,.348,.254,.274,3.53,.243 3,1,... &so on until
Devices' 200 John Collette FRAME,SUB FRAME,1V,2V,3V,4V,5V 1,1,.343,.234,.233,3.23,.233 2,1,.348,.254,.274,3.53,.243 &same amount of rows as 1st set ] I will be importing files in which, the amount of rows in the first set is not consistent. (so one file will have 300 rows, the next one 328,random amounts) How do I deal with the blank line that comes between the sets. Can I use it as a signifier that four lines of text are next?

1 comentario

Please post the format of the file formatting with the code button and seprating it from other text.
It's important to define the number of columns, so what happens to the line at ",... % so"?

Iniciar sesión para comentar.

 Respuesta aceptada

foo = textscan(fid,'%f%f%f%f%f%f%f','Delimiter',',','Whitespace','','HeaderLines',4)
This will skip the 4 header lines and read 7 floats per line after that. It will stop reading when it gets to EOF or a blank line. At that point you can repeat the textscan() as-is to get the next group.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by