Reading data from a specified point in a file
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!