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(inDa te, inFormat, outFormat):
return strftime(outFor mat, strptime(inDate , inFormat))
#the next part inside the loop reading the file:
.. .
newDate = changeDate(oldD ate, "%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\li b\_strptime.py" , line 424, in strptime
raise ValueError("tim e 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
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(inDa te, inFormat, outFormat):
return strftime(outFor mat, strptime(inDate , inFormat))
#the next part inside the loop reading the file:
.. .
newDate = changeDate(oldD ate, "%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\li b\_strptime.py" , line 424, in strptime
raise ValueError("tim e 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
Comment