Created
December 29, 2013 04:42
-
-
Save Chitrank-Dixit/8167522 to your computer and use it in GitHub Desktop.
Converting a Date from dd/mm/yyyy format to yyyy/mm/dd format in python a simple script The date are in the file 'testdate.txt' in dd/mm/yyyy format and after conversion look at convDate list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from dd/mm/yyyy to yyyy/mm/dd format of dates | |
f = open('testdate.txt') | |
i = f.read() | |
print i | |
date = i.split("\n") | |
print date | |
convDate = [] | |
for adate in date: | |
if '/' in adate: | |
curDate = adate[1:-1].split('/') | |
yymmdd = curDate[2] + '/' + curDate[1] + '/' + curDate[0] | |
print yymmdd | |
convDate.append(yymmdd) | |
print convDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment