Jul-04-2019, 06:45 PM
Hello to All!
I'm new in python programming and i need your help with the following problem. I have a CSV file with a column containing multiple dates. I want to use a loop (which ever works best) to iterate over the column of containing the dates, while at the same time during the iteration subtract today's date such if the difference between a date in the column and today's date equal a certain integer then it will print that date in the column that make produce that integer value. Please find the code snippet below. Thanks.
I'm new in python programming and i need your help with the following problem. I have a CSV file with a column containing multiple dates. I want to use a loop (which ever works best) to iterate over the column of containing the dates, while at the same time during the iteration subtract today's date such if the difference between a date in the column and today's date equal a certain integer then it will print that date in the column that make produce that integer value. Please find the code snippet below. Thanks.
#Load all necessary packages and modules import csv import datetime with open(r'myCSVpath', 'r') as csvFile: csv_file_reader = csv.DictReader(csvFile) for row in csv_file_reader: for row in csv_file_reader: #date2 = datetime.datetime.strptime(date2, "%Y-%m-%d").date() now = datetime.datetime.now() date2 = datetime.datetime.strptime(date2, "%Y-%m-%d").date() if (row['date'] = date2): if (date2 - now).days == 2: print(date2)