I have a problem converting excel xldate to python datetime with the following code. Is this the right way to convert?
import xlrd from datetime import datetime book = xlrd.open_workbook("a.xls") sh = book.sheet_by_index(0) for rx in range(1,sh.nrows): a = sh.row(rx) print a year, month, day, hour, minute = xlrd.xldate_as_tuple(a[0], book.datemode) py_date = datetime.datetime(year, month, day, hour, minute)
a is printed β
[xldate:40544.0, number:0.0, number:75.49847785316135, number:75.6401124106301]
The error is shown below.
year, month, day, hour, minute = xlrd.xldate_as_tuple(a[0], book.datemode) File "C:\Anaconda\Lib\site-packages\xlrd\xldate.py", line 67, in xldate_as_tuple xldays = int(xldate) TypeError: int() argument must be a string or a number, not 'Cell'
source share