deleted csv still being referenced python/datetime object -
i new python , having trouble outputs. using ipython write code well. want synchronize 2 clock times. first open csv time 1 source in 1 column , time source in other column. once find difference between values import csv has values time source lagging , add difference lagging clock standard other. problems: 1.when switch out first csv calculate time difference e.g (first csv time difference 5 min , new csv time difference 2 min) outputs have 5 min added instead of 2 min. have attached code can see. 2. don't know how convert datetime objects time objects rid of 1900-01-01. saw forums didn't understand code if there simple way appreciate it.
i know missing alot of basics appreciate help!
import csv datetime import time time_difference= open('test.csv') time_difference_csv=csv.reader(time_difference)#imports csv 2 #clock differences; e.g wall clock , scanner clock 1 value in each column firstline = true row in time_difference_csv: if firstline: #skip first line firstline = false continue # parse line row in time_difference_csv:#converts string values of clock #into datetimes allows them subtracted , added w = [[datetime.time.strptime(i[0],'%h:%m:%s')]+ [datetime.time.strptime(i[1],'%h:%m:%s')] in time_difference_csv] row in w:#gets difference btwn 2 clocks p= (row[1]-row[0]) row in w: l= (row[1]-row[0]) + row[0] td= open('121times3.csv')#imports csv list of times 1 time source; e.g. scanner times td_csv=csv.reader(td) firstline = true row in td_csv: if firstline: #skip first line firstline = false continue # parse line row in td_csv: k = [[datetime.time.strptime(i[0],'%h:%m:%s')] in td_csv] row in k:#adds difference found earlier times on csv. converts scanner times wall times. print row[0] + p
output 1900-01-01 10:37:09 1900-01-01 11:48:54 1900-01-01 11:19:08 1900-01-01 10:37:09 1900-01-01 11:48:54 1900-01-01 11:19:08 1900-01-01 10:37:09 1900-01-01 11:48:54 1900-01-01 11:19:08
Comments
Post a Comment