解决[1]:XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'id\xef\xbc\x8cage

报错

Traceback (most recent call last):
  File "C:/pythonfiles/cnn-hyoka/data_prcs/data_insert.py", line 7, in
    data = pd.read_excel(filepath)
  File "C:\Users\32728\AppData\Roaming\Python\Python36\site-packages\pandas\util\_decorators.py", line 188, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\32728\AppData\Roaming\Python\Python36\site-packages\pandas\util\_decorators.py", line 188, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\32728\AppData\Roaming\Python\Python36\site-packages\pandas\io\excel.py", line 350, in read_excel
    io = ExcelFile(io, engine=engine)
  File "C:\Users\32728\AppData\Roaming\Python\Python36\site-packages\pandas\io\excel.py", line 653, in __init__
    self._reader = self._engines[engine](self._io)
  File "C:\Users\32728\AppData\Roaming\Python\Python36\site-packages\pandas\io\excel.py", line 424, in __init__
    self.book = xlrd.open_workbook(filepath_or_buffer)
  File "C:\Users\32728\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\__init__.py", line 157, in open_workbook
    ragged_rows=ragged_rows,
  File "C:\Users\32728\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\book.py", line 92, in open_workbook_xls
    biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
  File "C:\Users\32728\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\book.py", line 1278, in getbof
    bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
  File "C:\Users\32728\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\book.py", line 1272, in bof_error
    raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'id\xef\xbc\x8cage'

代码

#读入数据
filepath = 'C:/pythonfiles/cnn-hyoka/users.csv'
data = pd.read_excle(filepath)

解决

read_ecle改read_csv  

别想着office excle 能打开CSV这里也能

#读入数据
filepath = 'C:/pythonfiles/cnn-hyoka/users.csv'
data = pd.read_csv(filepath)

 

你可能感兴趣的:(Python,Debug)