【Python】Pandas Excel file format cannot be determined, you must specify an engine manually.报错【已解决】

心中带点小风骚 2023年7月15日 上午11:21 Python

Pandas读取Excel报错

Excel file format cannot be determined, you must specify an engine manually.

pd.read_excel方法本身是支持多种引擎的,包括”xlrd”, “openpyxl”, “odf”, “pyxlsb”,更换引擎后依然失效!

Debug

我们直接用可以直接用open with打开源文件

    with open(ipath, 'r', encoding='utf-8') as f:
        print(f.read())

神奇的一幕发生了,

有的文件名义上是Excel,其实内心是个Html!

解决办法

使用pd.read_html方法

df = pd.read_html(ipath, header=2)[0]
        ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory    
    2023年7月15日
        ROS–服务通信    
    2022年3月8日
        搭建免费代理IP池    
    2023年3月7日
        【Matplotlib】plt.figure()、plt.subplot() 、plt.subplots() 、plt.xticks() 、plt.xlim()和 plt.grid() 六个函数的使用    
    2023年3月5日
        SPSS + AMOS 结构方程模型(SEM)    
    2023年3月5日
        python安装教程(windows)以及python环境变量设置以及在 cmd 输入 python 后不报错也无反应的问题    
    2023年6月11日
        tensorflow的安装    
    2022年3月15日
        python 使用networkx绘制带权无向图和带权有向图,以及标注特定路径    
    2023年3月5日