read formated text file

4 visualizaciones (últimos 30 días)
Luis Isaac
Luis Isaac el 13 de Abr. de 2021
Editada: Abhishek Gupta el 16 de Abr. de 2021
Dear
I have a very large file(250 MB aporx)
The first 8 lines are administrative information and the rest are the data itself
The data is well formated, and in fact without the first lines the whole file can be read with textscan(line, '%f %f %f %f)
Is it posible to applied the textscan intruction to a part of the file, i.e. how to discard the 8 first lines and use textscan (or something similar for the rest)
I've made some programs using for loop and fgets but the program takes some time to load the data becasuse the file is too big
Thanks
  1 comentario
Mario Malic
Mario Malic el 13 de Abr. de 2021
Check the documentation for the HeaderLines input argument.

Iniciar sesión para comentar.

Respuesta aceptada

Abhishek Gupta
Abhishek Gupta el 16 de Abr. de 2021
Editada: Abhishek Gupta el 16 de Abr. de 2021
Hi,
As per my understanding, you want to read a text file with 8 header lines. You can scan the text as follows: -
fid = fopen('mydata.txt');
data = textscan(fid, '%f %f %f %f', 'headerLines', 8);
fclose(fid);
For more details, check out the documentation link below: -

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by