Reputation: 29
I need to read 8760 files (365 days * 24 hours = 8760) of small size (60 kb) and aggregate values and take average of some values.
Earlier, I have used the below stated code for reading *.csv files:
for a=1:365
for b=1:24
s1=int2str(a);
s2=int2str(b);
s3=strcat('temperature_humidity',s1,'_'s2);
data = load(s3);
% Code for aggregation, etc
end
end
I was able to run this code. However now the file name is little different and I am not sure how to read these files.
Files are named like this:
2005_M01_D01_0000(UTC-0800)_L00_NOX_1HR_CONC.DAT
where M = Month, so the values are 01, 01, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12; D = Day, so the values are 01, 02, 03, ..., 31; Hours is in this format: 0000, 0100, 0200, ..., 1800, ..., 2300.
Please take a look at the attached image for file name . I need to read these files. Please help me.
Thank you very much.
Upvotes: 0
Views: 278
Reputation: 614
I would use dir:
files=dir('*.dat')
Or you can construct the filenames with
name = sprintf('%d_M%2d etc.',...)
Upvotes: 1