pythond assert 0 <= colx < X12_MAX_COLS AssertionError

python使用xlrd读取excel时,报错:
assert 0 <= colx < X12_MAX_COLS AssertionError

大意是excel列太多了。主要是xlrd库的问题。最好的方法是不用它,但是我用的其他人提供的工具用到它,没法改。

尝试手动删除excel的列,删除之后没有效果仍然报这个错误。

更改xlrd的库,具体参照https://stackoverflow.com/questions/37486558/assertionerror-with-pandas-when-reading-excel/51890047#51890047

将xlrd安装目录下的sheet.py修改
原代码:

if self.biff_version >= 80:
    self.utter_max_rows = 65536
else:
    self.utter_max_rows = 16384

新代码:

 #if self.biff_version >= 80:
 self.utter_max_rows = 65536
 #else:
 #      self.utter_max_rows = 16384

改完了还是报错。

查到X12_MAX_COLS的值是 2^14,在xlsx.py中定义,明显小于65536,我把它改成了2^16 + 1,也就是65537,然后就不报错了。

你可能感兴趣的:(python,python读取excel,python,xlrd)