In terms of storing datetime in pytables...there are a couple ways to go
about it floats and strings, with strings seeming to be preferable for
generic cross-platform use:

1)  store as double precision floats - Time64 in pytables - mapping to and
from python datetime's like so:

        t1 = time.time()
        t2 = datetime.datetime.fromtimestamp(t1)
        t3 = mktime(t2.timetuple())+1e-6*t2.microsecond

2)  store as ISO string, mapping to and from datetime in ugly way (let me
know if theres is a cleaner way) like so:

        t4 = t2.__str__()
        t4a, t4b = t4.split(".", 1)
        t5 = datetime.datetime.strptime(t4a, "%Y-%m-%d %H:%M:%S")
        ms = int(t4b.ljust(6,'0')[:6])
        t5 = t5.replace(microsecond=ms)

I found a discussion of the disadvantages of storing as float:

>* datetime isn't keen to use floating-point timestamps, because what
*>* 1053879135.83 means varies across platforms (not all boxes start counting
*at
>* 1970, and boxes disagree about whether leap seconds should be counted),
*and
>* because a float doesn't have enough bits of precision to represent all the
*>* date+time combinations datetime can represent.  Support for timestamps in
*>* the datetime module is thus minimal -- we're trying to move away from
*them.

...and to add to that there seems to be no time zone information in the
float representation.

And a worthwhile link... http://seehuhn.de/pages/pdate




On Nov 26, 2007 9:23 PM, Bradford Cross <[EMAIL PROTECTED]> wrote:

>
>
> On Nov 26, 2007 4:14 PM, David Worrall <[EMAIL PROTECTED]> wrote:
> >
> >  Numpy's necessity for data homogeneity means developing another level
> > of abstraction/conversion which was more fiddle. And for what gain?
> >  I decided to use something like your strategy 2:  read the relevant
> > data out of pytables into numpy arrays
> >
>
> This is what I am currently doing as well.  Write data to tables and
> create an API that allows access to the data as numpy arrays.
>
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to