I have this code:
def write_csv(path, inputdata):
with open(path, 'w', errors='ignore', newline='') as newfile:
writer = csv.writer(newfile, dialect='excel')
writer.writerows(inputdata)
I would like to write the date at the top of the CSV file. I tried to include
writer.writerow(datetime.date.today())
This as expected really returned _csv.Error: iterable expected, not datetime.date
How else could I do it? Include it as the fieldnames and write as a DictWriter
? I'm not confident that would work though.