Reading last lines in a text file
Ältere Kommentare anzeigen
Hey everyone!
I have a quick question. I want to read the last 100 data from a .txt file. The .txt will update now and then, but I need the last 100.
The file looks like this :
22 40866
18 40867
17 40868
9 40869
81 40868
81 40870
I'm using this code for reading :
fid = fopen('HCl.txt');
A = textscan(fid, '%s %s', 'delimiter', '\t');
fclose(fid);
I want to keep textscan because it reads in a way that I get arrays. A{1,1} and A{1,2}
A{1,1} = [22 18 17 9 81 81]
A{1,2} = [40866 40867 40868 40869 40868 40870 ]
So by reading(let's say) the last 2, I should get :
A{1,1} = [81 81]
A{1,2} = [40868 40870 ]
I found something but it applies only to fscanf which doesn't give out in arrays. It goes something like R = A(end,2:end)
Thank you in advance!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!