Reading data from a specified point in a file
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Fangjun Jiang
on 6 Aug 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 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!