Bug in strptime?
Henk-Jan de Jong
henkjan at xs4all.nl
Sun Oct 26 18:11:56 EST 2003
Hello all,
I'm completely new in Python and have the next problem. I have a huge file
with dates a want to convert from one format to another.
e.g 31-12-2003 should become 31122003. I'm using the next piece of code:
def changeDate(inDate, inFormat, outFormat):
return strftime(outFormat, strptime(inDate, inFormat))
#the next part inside the loop reading the file:
. .
newDate = changeDate(oldDate, "%d-%m-%Y", "%d%m%Y")
. .
When the file is small (less then 50 lines or so), it works fine. If the
file gets bigger I get the next error:
File "C:\Python23\lib\_strptime.py", line 424, in strptime
raise ValueError("time data did not match format: data=%s fmt=%s" %
ValueError: time data did not match format: data= fmt=%d-%m-%Y
What can be wrong?? The data seems ok.
Greetinx,
Matuka
More information about the Python-list
mailing list