[Tutor] unpacking PyTime
Etrade Griffiths
etrade.griffiths at dsl.pipex.com
Wed May 17 18:51:49 CEST 2006
Hi
I am using the Win32com library to pick up data from an EXCEL spreadsheet
but am having trouble with dates. I want to convert a date read from the
XL sheet into a float using this snippet
from win32com.client import dispatch
import time
xlFile="test.xls"
xlApp=Dispatch("Excel.Application")
xlApp.Workbooks.Open(xlFile)
xlSht=xlApp.Worksheets("data")
# OK so far but the problem comes now ...
curr_date=xlSht.Cells(1,3).Value # returns PyTime
Not how to get the date (as either yy,mm,dd or a single number aka
XL). The ASPN ActivePython site suggests using
x=curr_date.__float__()
but Python gives the error "AttributeError: __float__"
I also tried
x=float(curr_date)
but Python gives the error "TypeError: float() argument must be string or a
number". All suggestions gratefully received!
More information about the Tutor
mailing list