How to detect if a cell is empty when reading Excel files using the xlrd library?

前端 未结 1 1364
囚心锁ツ
囚心锁ツ 2020-12-09 12:12

I handle Excel files using the functions row_values and col_values:

import xlrd
workbook = xlrd.open_workbook( filename )
s         


        
相关标签:
1条回答
  • 2020-12-09 12:56

    You could be explicit and check that sheet.cell_type(rowno, colno) in (xlrd.XL_CELL_EMPTY, xlrd.XL_CELL_BLANK) but the docs state the value will be u'' where those are the case anyway.

    Instead of using row_values, you could also use row(n) which returns a list of Cell objects which have .value and .cell_type attributes.

    0 讨论(0)
提交回复
热议问题