I want to get only the numbers from a cell (excel). I tried the following:
uzemelteto = first_sheet.cell(17, 11)
res = [int(i) for i in uzemelteto.split() if i.isdigit()]
print res
But it gives an error like: AttributeError: 'Cell' object has no attribute 'split'
How can I modify it, to be able to get only digits?
worksheet.cell()
returns an object, namely an instance of the class Cell
(docs).
A Cell object has a property value
, so instead of
uzemelteto.split()
use
uzemelteto.value.split()
or, to be super safe, because the type of cell.value may vary based on the content, you can use
str(uzemelteto.value).split()