I think what I am trying to do is relatively easy but can't get my head around how to do it. I have a list of txt files that contain daily rainfall for many years. I would like to produce a list that contains the year-month and the max, min and mean of rainfall for each month. My main question at this stage is how to group the files by each month for each year? They are set out like: r20110101.txt r20110102.txt r20110103.txt r20110104.txt r20110105.txt r20110106.txt r20110107.txt r20110108.txt r20110109.txt r20110110.txt r20110111.txt r20110112.txt r20110113.txt r20110114.txt r20110115.txt r20110116.txt r20110117.txt r20110118.txt
and so on for each day for many years. so far I am able to open each file and calculate the max, min and mean for each file (see below) but not sure about grouping to monthly for each year. MainFolder=r"E:/Rainfalldata/" outputFolder=r"E:/test/" for (path, dirs, files) in os.walk(MainFolder): path=path+'/' for fname in files: if fname.endswith('.txt'): filename=path+fname f=np.genfromtxt(filename, skip_header=6) print f.max(), f.min(), f.mean() the ideal output would be something like: year-month max min mean 2010-12 100 0 50 2011-01 200 0 100 2011-02 50 0 25 any feedback will be greatly appreciated.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor