Borrar filtros
Borrar filtros

Reading data from a specified point in a file

2 visualizaciones (últimos 30 días)
Nora
Nora el 5 de Ag. de 2011
Hi All,
Given data in a text file that looks like the following
LAX2; LAX3; -; -; "6 7"; "2 4"; -; -; 10;
LAX1; LAX2; -; -; "7 8"; "2 4"; -; -; 10;
here
LAX1; LAX2; -; -; "7 8"; "2 4"; -; -; 10;
LAX4; -; -; -; "1 8"; "2 4"; -; -; 10;
LAX2; LAX3; -; -; "3 6"; "2 8"; -; -; 200;
I'd like to read from next line with data after the occurrence of 'here'. I'd also like to read one line at time. There are always 9 distinct pieces of data on each line.
Could someone tell me how to do this?
Thank you for your help!
-n

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 6 de Ag. de 2011
clc
fid=fopen('test.txt','rt');
line=fgetl(fid);
while ~feof(fid) && ~any(strfind(line,'here'))
line=fgetl(fid);
end
while ~feof(fid)
line=fgetl(fid)
% do stuff
end
fclose(fid);

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by