Automatic Downloading and automatic unzip of tarred and gunzipped files.
Mostra commenti meno recenti
So I the code I have currently can download several .tar.gz files within a loop, the amount of files downloaded can be altered by changing the variable year and the day within the file. After this succession of the loop, the code automatically progress onto the unzipping part, there is something at which I can't seem to crack is the fact that the code that is written only unzips the last file it downloads rather than all the files downloaded, what do I need to change to the code so that it would unzip all the files downloaded?
Many Thanks
url_https='https://data.cosmic.ucar.edu';
for year = 2022:2022
for day = 001:001
dataUrl = sprintf('%s/gnss-ro/cosmic2/nrt/level1b/%d/%03d/podTc2_nrt_%d_%03d.tar.gz',url_https, year, day, year, day);
dataFile = sprintf('podTc2_nrt_%d_%03d.tar.gz', year, day);
FileFullPath = websave(dataFile, dataUrl);
end
end
DownloadedFile=sprintf('podTc2_nrt_%d_%03d', year, day);
unzip_Files=untar(FileFullPath,DownloadedFile);
ncvars={'TEC','elevation','time','x_LEO','y_LEO','z_LEO','x_GPS','y_GPS','z_GPS'};
projectdir=(DownloadedFile);
dinfo=dir(fullfile(projectdir,'*.0001_nc'));
num_files=length(dinfo);
filenames=fullfile(projectdir,{dinfo.name});
TECs=cell(num_files,1);
Elevations=cell(num_files,1);
times=cell(num_files,1);
x_LEOs=cell(num_files,1);
y_LEOs=cell(num_files,1);
z_LEOs=cell(num_files,1);
x_GPSs=cell(num_files,1);
y_GPSs=cell(num_files,1);
z_GPSs=cell(num_files,1);
for i=1 : num_files
this_file=filenames{i};
TECs{i}=ncread(this_file,ncvars{1});
Elevations{i}=ncread(this_file,ncvars{2});
times{i}=ncread(this_file,ncvars{3});
x_LEOs{i}=ncread(this_file,ncvars{4});
y_LEOs{i}=ncread(this_file,ncvars{5});
z_LEOs{i}=ncread(this_file,ncvars{6});
x_GPSs{i}=ncread(this_file,ncvars{7});
y_GPSs{i}=ncread(this_file,ncvars{8});
z_GPSs{i}=ncread(this_file,ncvars{9});
delete(this_file)
end
1 Commento
Tianchu Lu
il 12 Set 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Downloads in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!