Bug in strptime?

Henk-Jan de Jong henkjan at xs4all.nl
Mon Oct 27 14:41:56 EST 2003


John,

good advice! I figured out it's not strptime but some feature in the
linesplitter I wrote :(

Thanx

Matuka

"John Roth" <newsgroups at jhrothjr.com> wrote in message
news:vpolq11905p946 at news.supernews.com...
>
> "Henk-Jan de Jong" <henkjan at xs4all.nl> wrote in message
> news:3f9c54bc$0$58714$e4fe514c at news.xs4all.nl...
> > 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.
>
> Put a try block around the line causing the error, and print out the
> input line at that point.
>
> There is a high probability that enlightenment will occur...
>
> John Roth
> >
> > Greetinx,
> >
> > Matuka
> >
> >
>
>






More information about the Python-list mailing list