pyExcelerator question - dates map to floats?
skip at pobox.com
skip at pobox.com
Sat Sep 9 23:55:20 EDT 2006
I'm experimenting with pyExcelerator and am reading an XLS file which
contains dates. In Excel on my Mac they look like "09/13/06". After
parsing them out of the .XLS file they are floats, e.g. 38973.0. I assume
that's an offset in days. Doing a little date math I come up with a base
date of approximately (though not quite) 1900-01-01:
>>> import datetime
>>> dt = datetime.timedelta(days=-38973)
>>> datetime.date(2006, 9, 13) + dt
datetime.date(1899, 12, 30)
>>> datetime.date(1900, 1, 1) - dt
datetime.date(2006, 9, 15)
Is there some way to get pyExcelerator from doing this conversion and
instead return dates as strings? If I'm reading an arbitrary worksheet and
don't know which columnn might be a date, it's kind of hard to guess.
Skip
More information about the Python-list
mailing list