Reputation: 129
I have a CSV file where the date is formatted as yy/mm/dd
, but Excel is reading it wrongly as dd/mm/yyyy
(e.g. 8th September 2015 is read as 15th of September 2008).
I know how to change the format that Excel outputs, but how can I change the format it uses to interpret the CSV data?
I'd like to keep it to Excel if possible, but I could work with a Python program.
Upvotes: 0
Views: 1653
Reputation: 59495
Use DATA, Get External Data, From Text and when the wizard prompts you choose the appropriate DMY combination (Step 3 of 3, Under Column data format, and Date).
Upvotes: 4
Reputation: 114088
edit: a better method is suggested in the OP comments to accomplish this, I was not aware you could do that
it(excel) uses your windows settings
so you can go to
Control Panel > Clock, Language, Region > (under Region and Language) change the date,time or number format
and enter the appropriate format
from dateutil.parser import parse
with open("output.csv","wb") as fout:
csv_out = csv.writer(fout)
for row in csv.reader(open("input.csv","rb")):
row[date_index] = parse(row[date_index]).strftime("%x")
csv_out.writerow(row)
Upvotes: 1