import os import codecs import datetime import dataset #fw=codecs.open('c:/tmp/halfday.csv','w','utf-8') fw=codecs.open('c:/tmp/hour.csv','w','utf-8') fw.write('aaa\n') fw.write('aaa\n') #fr=codecs.open('c:/tmp/h12.csv','r','utf-8') #fr=codecs.open('c:/tmp/m30.csv','r','utf-8') fr=codecs.open('c:/tmp/h1.csv','r','utf-8') lines=fr.readlines()[1:] fr.close() for l in lines: elmts=l.split('\t') o=int(float(elmts[2])*10000) h=int(float(elmts[3])*10000) l=int(float(elmts[4])*10000) c=int(float(elmts[5])*10000) dt=elmts[0].replace('.','/')+" "+elmts[1]+","+str(o)+","+str(h)+","+str(l)+","+str(c)+',0,\n' entry=dt fw.write(entry) print(entry) fw.close()