Reputation: 110203
If I do:
print sh.cell(1,col)
I get:
text:u''
text:u''
text:u'eng'
text:u''
xldate:41450.0
number:11.0
number:30.0
text:u'Reality TV'
However, if I do: print type(sh.cell(1,col))
, I get:
<class 'xlrd.sheet.Cell'>
for all.
How would I get "text" or "xldate" or "number" -- i.e., the cell type -- from xlrd?
Upvotes: 6
Views: 3678
Reputation: 184201
You want the ctype
attribute of the Cell
object. E.g.:
sh.cell(1,col).ctype
This is an integer that indicates the cell type. You want to compare to xlrd.XL_CELL_DATE
; see documentation here.
Upvotes: 12
Reputation: 110203
I did this a hack-ish way:
if str(sh.cell(1,col)).split(':')[0] == 'xldate':
Upvotes: 1