You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用llama-index读取多Sheet Excel报错:PandasExcelReader无_concat_rows属性

解决llama-index读取多工作表Excel时的AttributeError问题

你遇到的问题源于llama-index 0.6.0版本的PandasExcelReader类存在bug:构造函数未初始化_concat_rows属性,但load_data方法中却直接引用了它。以下是几种可行的解决办法:

  • 升级llama-index到稳定版
    旧版本的bug在后续更新中已被修复,执行命令完成升级:

    pip install --upgrade llama-index
    
  • 初始化loader时显式传入参数
    创建PandasExcelReader实例时,通过concat_rows参数初始化对应的内部属性,同时修正sheet_name的大小写错误(Python中None需大写):

    from pathlib import Path
    from llama_index import download_loader
    
    PandasExcelReader = download_loader("PandasExcelReader")
    
    # concat_rows=True表示合并所有工作表的行,False则保留各工作表独立文档
    loader = PandasExcelReader(concat_rows=True)
    documents = loader.load_data(file=Path('dir1/excel.xlsx'), sheet_name=None)
    
  • 手动添加缺失的属性
    若暂时无法升级版本,可在创建实例后手动补充_concat_rows属性:

    from pathlib import Path
    from llama_index import download_loader
    
    PandasExcelReader = download_loader("PandasExcelReader")
    
    loader = PandasExcelReader()
    loader._concat_rows = True  # 根据需求设置为True或False
    documents = loader.load_data(file=Path('dir1/excel.xlsx'), sheet_name=None)
    

内容的提问来源于stack exchange,提问作者user2966197

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 10:24:59