I have a csv file containing years of data, and I need to calculate the difference between two dates (the max date and the min date), so I believe that I should extract the max date and the min date.
Here's my data :
timestamp,heure,lat,lon,impact,type
2006-01-01 00:00:00,13:58:43,33.837,-9.205,10.3,1
2006-01-02 00:00:00,00:07:28,34.5293,-10.2384,17.7,1
2007-02-01 00:00:00,23:01:03,35.0617,-1.435,-17.1,2
2007-02-02 00:00:00,01:14:29,36.5685,0.9043,36.8,1
....
2011-12-31 00:00:00,05:03:51,34.1919,-12.5061,-48.9,1
I am proceeding as bellow in my code :
W=np.loadtxt(dataFile,delimiter=',',dtype={'names': ('datum','timestamp','lat','lon','amp','ty'),
'formats':('S10', 'S8' ,'f4' ,'f4' ,'f4','S3' )})
day = datetime.strptime(W['datum'][0],'%Y-%m-%d')
time=[]
for i in range(W.size):
timestamp = datetime.strptime(W['datum'][i]+' '+W['timestamp'][i],'%Y-%m-%d %H:%M:%S')
Tempsfinal = max(timestamp)
Tempsinitial = min(timestamp)
interval=int((Tempsfinal- Tempsinitial)/6)
So, doing this I got the error:
datetime.datetime' object is not iterable
How can I proceed?