Working with Zipped Files

4 views (last 30 days)
Rodrigo Valdés-Pineda
Rodrigo Valdés-Pineda on 23 Dec 2013
Answered: Walter Roberson on 24 Dec 2013
Hello all,
I'm trying to extract data from hundreds of zipped files. I was able to do it, but what I really need is to determine a restriction over them. Each zipped file contains hourly data, and off course there is missed files (hours) within the whole dataset. I want to aggregate the data at daily scale but I have not been able to do it because missed information. What I have been trying to do is to create "NaN - undefined - blank" for the missed files (vector of cell arrays), by comparing the names of the files, for example "Data.201319909.gz" (where 2013=year 199=Julian Day 09=hour), to the real period of the series being analyzed. The idea is to find the missed files, and create a vector of cell arrays (same length of the real period) containing the name of all original .gz files, and including new files created with the corresponding name using the same format than the original ones.
This is how I get the name of the files:
ruta2=dir(char({[ruta,'\','*.gz']}));
n=length(ruta2);
for i=1:n
datname{i,1}=ruta2(i,1).name;
end
and this how I created a vector with the real period:
DataStart = [2013 199 00];
DataEnd = [2013 199 23];
k=0;
for i=DataStart(2):DataEnd(2)
for j=DataStart(3):DataEnd(3)
k=k+1;
Mdtime(k,1)=2013;
Mdtime(k,2)=i;
Mdtime(k,3)=j;
end
end
as I mentioned I could to unzip the files and read them but I need to deal with the recognizing of missed files, and the creation of "fakes ones files" to create a dataset with the same length than the real period. From my point of view that should allow to aggregate daily data easily.
Any idea or help? thanks, :-)

Answers (1)

Walter Roberson
Walter Roberson on 24 Dec 2013
Creating a fake file should work. It is not clear what you are asking for ?
http://www.mathworks.com/help/matlab/ref/addtodate.html might help you create the month/day combinations that exist and thus help you create the file names.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!