I need to exchange dateformats in a large csv from DD/MM/YYYY to YYYY-MM-DD. I have no problem printing out the values I want them to replace with, but I have a hard time actually overwriting the csv.
Here is my code:
import csv from datetime import datetime with open('partner_new_testteam.csv', newline='') as data: reader = csv.reader(data) for list in reader: for string in list: try: datetimeobject = datetime.strptime(string, '%d/%m/%Y') changedDate = datetimeobject.strftime('%Y-%m-%d') print(changedDate) except: continue I know this code is rather sloppy, but keep in mind that I just started programming, thanks in advance!