use regexp to find specific names.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I've been trying to download some specific files from the web with name
'DPR-NS-12755-V04A.MRMS-XXXXXXXX.114200.matched-130W_55W_20N_55N.extract.dat'
The XXXXXXXX is the yyyymmdd that changes with the loop. I used regexp. But it returns just XXXXXXXX and not the entire name. I used something ugly (which worked finally) to download my file as:
expr = [sprintf('%02.0f', y), sprintf('%02.0f', m), sprintf('%02.0f', d)];
% y = year, m = month, d is day
a = regexp(str,expr);
filename=str(a-22:a+51);
I know it is very armature to use something like this!. Can you help me to parcel the name of these files in a more professional way? I read the regexp doc in Matlab but it is a little confusing for me.
Thanks,
Zeinab
0 commentaires
Réponses (1)
mizuki
le 31 Déc 2016
Use datetime instead of regular expressions:
% from 2016/12/01 to 2016/12/10 with every other day
datevec = datetime(2016,12,01):day(2):datetime(2016,12,10);
t = datestr(datevec, 'yyyymmdd');
for i = 1:size(t,1)
filename = ['DPR-NS-12755-V04A.MRMS-', t(i,:), '114200.matched-130W_55W_20N_55N.extract.dat'];
% webread(filename)
end
3 commentaires
Voir également
Catégories
En savoir plus sur Downloads dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!