Extract all indexes inside a text file
Afficher commentaires plus anciens
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 commentaires
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
le 3 Juin 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!