I’m using Python’s csv.reader to bring a set of dates & coordinates from a file into a list. Here’s a sample line from the .csv and the code:
2012-05-06,2012-05-13,165,35.20068,-89.79318
with open('innovation.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
parseMe.append(row)
The problem is that for some reason, when the date is put into the list, the string is being changed from an ISO format to a calendar format:
[‘5/6/2012’, ‘5/13/2012’, ‘35.20068’, ‘-89.79318’]
Any thoughts on what is happening here? Is it something csv.reader that is changing the strings? What can I do to prevent it or change it back to the ISO format?
csv.readeris not changing anything. The file you think is being opened is probably not the same as the file that is actually being opened.To prove this run:
The most likely cause of this is that the
'inovation.csv'file you are looking at is in a different directory than the'inovation.csv'that your program is opening.