To do something when the cell is not empty, add:
if cell.value:
which in python is the same as if the cell value was not None (for example: if not cell.value == None :)
Note. To avoid checking empty cells, you can use
worksheet.get_highest_row()
and
worksheet.get_highest_column()
I also found this useful (although it may not be a good solution) if you want to use the contents of the cell as a string, regardless of the type you can use:
unicode(cell.value)
Aron kisdi
source share