csvList = [] for i in range(0, flow.numberValues): # print int(flow.times[i]) time = HecTime() time.set(int(flow.times[i])) d = [ time.year(), '%d' % (time.month(), ), '%d' % (time.day(), ) ] t = [ '%d' % (time.hour(), ), '%d' % (time.minute(), ), '%d' % (time.second(), ) ] if (int(t[0]) > 23): t[0] = '23' dtStr = '-'.join(str(x) for x in d) + ' ' + ':'.join( str(x) for x in t) dt = datetime.datetime.strptime(dtStr, '%Y-%m-%d %H:%M:%S') dt = dt + datetime.timedelta(hours=1) else: dtStr = '-'.join(str(x) for x in d) + ' ' + ':'.join( str(x) for x in t) dt = datetime.datetime.strptime(dtStr, '%Y-%m-%d %H:%M:%S') csvList.append([ dt.strftime('%Y-%m-%d %H:%M:%S'), "%.2f" % flow.values[i]
else : csvWriter.writerow(['Location Ids', 'Hanwella']) csvWriter.writerow(['Time', 'Flow']) print flow.values[:1], flow.times[:1] print flow.values[-1], flow.times[-1] csvList = [] for i in range(0, flow.numberValues) : # print int(flow.times[i]) time = HecTime() time.set(int(flow.times[i])) d = [time.year(), '%d' % (time.month(),), '%d' % (time.day(),)] t = ['%d' % (time.hour(),), '%d' % (time.minute(),), '%d' % (time.second(),)] if(int(t[0]) > 23) : t[0] = '23' dtStr = '-'.join(str(x) for x in d) + ' ' + ':'.join(str(x) for x in t) dt = datetime.datetime.strptime(dtStr, '%Y-%m-%d %H:%M:%S') dt = dt + datetime.timedelta(hours=1) else : dtStr = '-'.join(str(x) for x in d) + ' ' + ':'.join(str(x) for x in t) dt = datetime.datetime.strptime(dtStr, '%Y-%m-%d %H:%M:%S') csvList.append([dt.strftime('%Y-%m-%d %H:%M:%S'), "%.2f" % flow.values[i]]) print csvList[:3], "...", csvList[-3:] csvWriter.writerows(csvList) except Exception, e :