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?
Best Answers you can use - ISTEXT([Your Column Name]) to check if it's a text entry and ISDATE([Your Column Name]) if it's a date. Instead of adding the ISTEXT for each of the columns, you can replace each of the ISDATE criteria to just say if the cell is not blank.
In a blank cell enter the formula =COUNTA(A1:E15), and press the Enter key. In the formula, the range A1:E15 is the specific range you will count numbers of cells with data, and you can change it as you need.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With