gpt4 book ai didi

excel - Pandas 0.22.0 : IndexError: list index out of range when reading xls

转载 作者:行者123 更新时间:2023-12-04 16:06:19 25 4
gpt4 key购买 nike

我正在尝试将 282Mb(65536 行 x 138 列).xls 文件加载到 pandas 数据框中

import pandas as pd
import os

filename = r'invoicing.xls'
dir = os.path.dirname(os.path.abspath(filename))
excelFile = os.path.join(dir, filename)
invoicing_info = pd.read_excel(excelFile)

但是我明白了

Traceback (most recent call last):
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/sheet.py", line 698, in put_cell_unragged
self._cell_types[rowx][colx] = ctype
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/juanda/PycharmProjects/Hyperion_info/load_info.py", line 11, in <module>
invoicing_info = pd.read_excel(excelFile, sheet_name=0)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/pandas/util/_decorators.py", line 118, in wrapper
return func(*args, **kwargs)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/pandas/io/excel.py", line 230, in read_excel
io = ExcelFile(io, engine=engine)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/pandas/io/excel.py", line 294, in __init__
self.book = xlrd.open_workbook(self._io)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/__init__.py", line 162, in open_workbook
ragged_rows=ragged_rows,
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/book.py", line 107, in open_workbook_xls
bk.fake_globals_get_sheet()
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/book.py", line 728, in fake_globals_get_sheet
self.get_sheets()
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/book.py", line 719, in get_sheets
self.get_sheet(sheetno)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/book.py", line 710, in get_sheet
sh.read(self)
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/sheet.py", line 1361, in read
self_put_cell(rowx, colx, None, d, self.fixed_BIFF2_xfindex(cell_attr, rowx, colx))
File "/Users/juanda/conda_envs/Hyperion_contracts_env/lib/python3.6/site-packages/xlrd/sheet.py", line 709, in put_cell_unragged
assert 1 <= nr <= self.utter_max_rows
AssertionError

我认为这是 .xls 扩展名的问题,但我无法在上传文件之前对其进行修改。如何以可靠的方式上传此 .xls 文件?

最佳答案

我遇到了同样的问题。在我将“仅值”复制并粘贴到新工作表中后,移动工作表(工作表的顺序),它现在可以工作了。这很烦人。

关于excel - Pandas 0.22.0 : IndexError: list index out of range when reading xls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48669253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com