Pandas.read_excel: Unsupported format, or corrupt file: Expected BOF record

前端 未结 2 1569
南笙
南笙 2021-01-06 20:33

I\'m trying to use pandas.read_excel to read in .xls files. It succeeds on most of my .xls files, but then for some it errors out with the following error message:



        
相关标签:
2条回答
  • 2021-01-06 21:11

    I solved this problem loading it with pd.read_table (it loads everything into one column)

    df = pd.read_table('path/to/xls_file/' + 'my_file.xls')
    

    then I split this column with

    df = df['column_name'].str.split("your_separator", expand=True)
    
    0 讨论(0)
  • 2021-01-06 21:19

    There are various reasons to why that error message appeared. However, the main reason could be due to the Excel file itself. Sometimes, especially if you're pulling an Excel file from some Reporting Portal, the Excel file could be corrupt so the best thing would be to open the Excel file and save it as a new .xls file then retry running pandas.read_excel.

    Lemme know if it works.

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