How can I skip lines when reading from a text file

21 visualizaciones (últimos 30 días)
Ahmed
Ahmed el 19 de Jul. de 2013
Comentada: Berenice Cervantes el 6 de Mayo de 2020
Hello All,
I have a text file with the extension .rep
I need to skip the first 36 lines and then start reading numeric data.
How can I do this?
Thanks alot,
Ahmed

Respuesta aceptada

David Sanchez
David Sanchez el 19 de Jul. de 2013
You could try the built-in function fgets:
fid = fopen('my_file.m');
% read the first 36 lines and do nothing to them
for k=1:36
tline = fgets(fid);
end
% next reading will be on 37th line.
% display form 37th line forward:
while ischar(tline)
disp(tline)
tline = fgets(fid);
end
fclose(fid)
For more details, type:
help fgets
doc fgets

Más respuestas (1)

YUMIN HO
YUMIN HO el 14 de Jun. de 2019
thank you for the answer

Categorías

Más información sobre Low-Level File I/O 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