On Dec 16, 2007 5:26 PM, Andrew Straw <[EMAIL PROTECTED]> wrote:

> As a followup to the work on floats, I fixed rec2csv to deal with funky
> strings (strings with commas and quotes). I've checked this is as r4749,
> but I thought I'd announce here in case someone (John, in particular)
> was depending on some peculiar aspect of the old implementation. If
> there is something you depend on, can you update the unittests in
> unit/mlab_unit.py to check for the behavior you need?

OK, I found one problem with repr.  When adding support for date vs
datetime to the csv2rec roundtrip, and adding this to the unit test, I
notice that repr is probably not what we want for datetime; str makes
more sense here:

In [1]: import datetime

In [2]: d = datetime.date.today()

In [3]: repr(d)
Out[3]: 'datetime.date(2007, 12, 16)'

In [4]: str(d)
Out[4]: '2007-12-16'

The latter is more natural in the CSV file, and the repr version is
not supported by dateutil, at least not the one we are shipping:

In [5]: import dateutil.parser

In [6]: dateutil.parser.parse(repr(d))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/Users/jdhunter/python/svn/matplotlib/examples/<ipython console> in <module>()

...snip the rest of the traceback...

In [7]: dateutil.parser.parse(str(d))
Out[7]: datetime.datetime(2007, 12, 16, 0, 0)


So I changed FormatObject to use str, pending further discussion.  At
least for my common use cases, the only obj types I have in my record
arrays are dates and datetimes, and I find this to be a pretty
compelling use case since it is the type least likely to be supported
by other persistence methods (tostring and pickle both fail or do not
behave as expected with datetimes in the recarray).

But there is an oddity in the parsing of milliseconds which is causing
the updated unit test to fail; the code below illustrates the problem:

In [3]: import dateutil.parser

In [4]: import datetime

In [5]: s = '2007-12-18 22:29:34.924122'

In [6]: dateutil.parser.parse(s)
Out[6]: datetime.datetime(2007, 12, 18, 22, 29, 34, 924121)

Thoughts?

JDH

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to