Extract all indexes inside a text file
Ältere Kommentare anzeigen
How can I extract all the indexes from the following text file? It works for 01June2020 but not for 04June2020.
fid = fopen('01JUNE2020_0000Z.TXT');
cnt=0;
while ~feof(fid)
aa = fgetl(fid);
if length(aa) >= 68
aa = [aa,''];
if strcmp(aa(1:67),' 1 CAPE Total ')
Cape_Total(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 K Index ')
K_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 LI - Lifted Index ')
Lifted_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 SI - Showalter Index ')
Showalter_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 SWEAT Index ')
SWEAT_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 TT - Total Totals ')
Total_Totals(cnt,1) = str2num(aa(67:length(aa)));
end
cnt = cnt + 1;
end
display(cnt)
end
2 Kommentare
There do not appear to be any numbers associated with those rows in the ‘04JUN2020’ file:
opts = weboptions('ContentType','text');
W1 = webread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1020870/01JUNE2020_0000Z.TXT', opts)
W2 = webread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1020875/04JUNE2020_0000Z.TXT', opts)
.
Munir Baldomero
am 3 Jun. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Timetables 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!