I am trying to compare a date I extracted from a csv file to the current date, to check if the difference is bigger than seven days. Here is my code:
with open (path) as csvfile:
readcsv = csv.reader(csvfile, delimiter = ',')
for row in readcsv:
iso_ts = str(row[3])
datum = (datetime.datetime.strptime(''.join(iso_ts.rsplit(':', 1)), '%Y-%m-%dT%H:%M:%S%z'))
current_time = (datetime.datetime.strptime(datetime.datetime.now(),'%Y-%m-%dT%H:%M:%S%z'))
Without even comparing these I get the following error
File "./netapp.py", line 32, in <module>
current_time = (datetime.datetime.strptime(datetime.datetime.now(),'%Y-%m-%dT%H:%M:%S%z'))
TypeError: must be str, not datetime.datetime
I would like to check, if the data coming from the csv is older than 7 days to the current date and then do something. I know this is some problem with the format of either one of these dates, but i can not seem to figure out what it is exactly. I would be very grateful for an explanation about what I am missing.