Reading data from a specified point in a file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
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);
0 comentarios
Más respuestas (0)
Ver también
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!