Reading data from a specified point in a file

1 回表示 (過去 30 日間)
Nora
Nora 2011 年 8 月 5 日
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

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 6 日
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 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by