how to convert UNICODE to integer in Python?

kath nitte.sudhir at gmail.com
Fri Oct 6 06:53:44 EDT 2006


Hi,

>>> import xlrd
>>> book = xlrd.open_workbook("testbook1.xls")
>>> sh = book.sheet_by_index(0)
>>> sh.cell_value(rowx=1,colx=0)
38938.0
>>> type(sh.cell_value(rowx=1,colx=0))
<type 'unicode'>
>>> xlrd.xldate_as_tuple( sh.cell_value( rowx = 1,colx= 0 ), 0 )

Traceback (most recent call last):
  File "D:\Python23\Testing area\Python and Excel\xlrdRead.py", line
30, in ?
    temp=xlrd.xldate_as_tuple(sh.cell_value(rowx=r,colx=c),0)
  File "D:\PYTHON23\Lib\site-packages\xlrd\xldate.py", line 61, in
xldate_as_tuple
    xldays = int(xldate)
ValueError: invalid literal for int(): Date

because xlrd.xldate_as_tuple() function expects first argument to be an
integer. How do I convert an unicode character to integer, so that I
could get the date using xlrd.xldate_as_tuple() function.

Thank you,
kath.




More information about the Python-list mailing list