### rain4hours01.py import datetime daHour=0 daRain4Hour=float(0) rainfall4days = [] inFile = open("rainGuageRainfall.txt", "rt") outFile = open("rainfall4HoursSourceFileDump.txt", "wt") for line in inFile: x = line.split(", ") epochTime=x[0] rainfall=x[1] rainfallStripped=rainfall.strip() ###print("epochTime: ", epochTime, "rainfall: ", rainfall) outFile.write(line) hour4Rain= datetime.datetime.utcfromtimestamp(int(epochTime)).strftime('%d') print(hour4Rain) if daHour == int(hour4Rain): daRain4Hour = daRain4Hour + float(rainfallStripped) writeArg = str(daHour) + " - " + hour4Rain + " in if - " + str(daRain4Hour) + "\n" outFile.write(writeArg) else: if int(hour4Rain) > daHour: daRain4HourRounded=round(daRain4Hour,2) print(daHour, daRain4HourRounded) daRain4Hour = 0 daHour = daHour +1 writeArg = str(daHour) + " - " + hour4Rain + "in else - " + str(daRain4Hour) + "\n" outFile.write(writeArg) else: writeArg = str(daHour) + " - " + hour4Rain + "in else - " + str(daRain4Hour) + "\n" outFile.write(writeArg) inFile.close() outFile.close() while daHour < 32: print(daHour, 0) daHour=daHour+1