How do I identify the a specific row number in a .txt file?
Show older comments

Hello folks,
Ive got a .txt file shown above. I want to identify the row number of the circled entry (Time (s)). So, if im not mistaken, 26.
I read other similair questions and tried this:
fid = fopen('C:\wherever\textymctextface.txt', 'rt');
s = textscan(fid, '%s', 'delimiter', '\n');
loc = find(strcmp(s{1}, 'Time (s)'), 1, 'first');
So the struct s created looks fine, until the 17th row (Type Time Duration Comment). In this row, it groups the next 6 rows in that same row. So in Matlab, the variable looks like:

What gives? Why does this happen? The new row delimeter is the same throughout, and since the number of Comments is different for different files I cant just account for them.
So: how do I fix my code or does anyone have any other ideas to go about this?
Thank you!!!
R
Accepted Answer
More Answers (1)
fbaillon
on 4 Aug 2017
Have you tried with the delimiters '\r\n'?
s = textscan(fid, '%s', 'delimiter', '\r\n');
1 Comment
Rafael Cordero
on 4 Aug 2017
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!