I have the date of 1515 in my data set column 4, is there any way to bypass this error?
cols[4] = cols[4] and cols[4].strftime("%d/%m/%Y") or ""
ValueError: year=1515 is before 1900; the datetime strftime() methods require year >= 1900
Here is the exact code:
cursor.execute(SQL)
filename = r"C:\Projects\OPEN_KCI3.csv"
with open(filename, "wb") as fout:
writer = csv.writer(fout)
#writer.writerow([i[0] for i in cursor.description ]) # heading row
for row in cursor.fetchall():
cols = list(row)
cols[3] = cols[3] and cols[3].strftime("%d/%m/%Y") or ""
cols[4] = cols[4] and cols[4].strftime("%d/%m/%Y") or ""
writer.writerow(cols)
cursor.close()
connection.close()