fgetl, textscan, and the file position indicator
4 views (last 30 days)
Show older comments
Is a construct like this legal?
It doen't return any error, but the "file position indicator" is not advanced as it should. I read a text file CRLF for new line.
fid = fopen( ... );
str = fgetl( fid );
cac = textscan( fid, ... );
...
str = fgetl( fid );
cac = textscan( fid, ... );
fclose( fid )
0 Comments
Accepted Answer
Walter Roberson
on 7 Sep 2012
Edited: Walter Roberson
on 7 Sep 2012
That series is valid, yes.
Did you open the file with 'rt' instead of 'r' in order to account for the CRLF ?
Also note that if you use a count for textscan() then the file position will be left after the last format code is used, before the newline for that line (unless the end of format matches newline)
0 Comments
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data 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!