Various strings to dates.

Amy G amy-g-art at cox.net
Fri Jan 23 18:29:27 EST 2004


Okay.  I fixed the problem somewhat.  I moved the dateutil directory over to
/usr/local/lib/python2.2/site-packages and I can now import dateutil.  But a
call like this:

from dateutil.parser import parse

results in this error:

ImportError: cannot import name parse

I can 'from dateutil.parser import *' but cannot use parse after that.
I can also 'from dateutil import parser' but that doesn't help either.

Sorry for my inexperience here.  Thanks for all of the help already.

"Amy G" <amy-g-art at cox.net> wrote in message
news:PRgQb.16209$AA6.9881 at fed1read03...
> No it won't.  Unfortunatly I don't necessarily have a comma delimited date
> string.  Thanks for the input though.
>
> The following three date strings is another example of the various date
> formats I will encounter here.
>
> Thursday, 22 January 2004 03:15:06
> Thursday, January 22, 2004, 03:15:06
> 2004, Thursday, 22 January 03:15:06
>
> All of these are essentially the same date... just in various formats.  I
> would like to parse through them and get a comparable format so that I can
> display them in chronological order.
>
>
> "wes weston" <wweston at att.net> wrote in message
> news:MFgQb.95539$6y6.1915432 at bgtnsc05-news.ops.worldnet.att.net...
> > Amy,
> >     I hope there is a better way but, if you go here:
> >
> > http://www.python.org/doc/current/lib/datetime-date.html
> >
> > The new datetime module may help. This and the time mod
> > should get you where you want to go.
> >
> > list     = strdate.split(", ")
> > daystr   = list[0]
> > daynum   = int(list[1])
> > monthstr = list[2]
> > year     = int(list[3])
> > #funct to get a month int is needed
> >
> > d = datetime.Date(y,m,d)
> >
> > wes
> >
> > ---------------------------------------
> >
> > Amy G wrote:
> > > I have seen something about this beofore on this forum, but my google
> search
> > > didn't come up with the answer I am looking for.
> > >
> > > I have a list of tuples.  Each tuple is in the following format:
> > >
> > > ("data", "moredata", "evenmoredata", "date string")
> > >
> > > The date string is my concern.  This is the date stamp from an email.
> > > The problem is that I have a whole bunch of variations when it comes
to
> the
> > > format that the date string is in.  For example I could have the
> following
> > > two tuples:
> > >
> > > ("data", "moredata", "evenmoredata", "Fri, 23 Jan 2004 00:06:15")
> > > ("data", "moredata", "evenmoredata", "Thursday, 22 January 2004
> 03:15:06")
> > >
> > > I know there is some way to use the date string from each of these to
> get a
> > > date usable by python, but I cannot figure it out.
> > > I was trying to use time.strptime but have been unsuccesful thus far.
> > >
> > > Any help is appreciated.
> > >
> > >
> >
>
>





More information about the Python-list mailing list