XLRD错误通过pandas

当我尝试pd.read_excel()时出现以下错误。 这个错误是特定于我的电脑的:当我在不同的计算机上使用相同的文件运行脚本时,不会发生错误。 Python 3.6.1的Anaconda发行版。 pandas版本'0.20.3' ,Xlrd版本'1.1.0'

XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\x08jstanle' XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\x08jstanle'是我的电脑名称,所以这可能是一个很大的暗示,我错过了。

它试图打开.xls或.xlsx文件。 我试过改变扩展到旧的和新版本的Excel没有任何改变。

谢谢您的帮助! 我会把下面的完整错误的位。

 C:\Users\jstanley\Documents\----\---\Python\load_data_original.py in load_(exp_id, file_path) 60 61 def load_(exp_id, file_path): ---> 62 dict_sheets = pd.read_excel(file_path, header=None, sheetname=None) 63 new_dict_sheets = dict() 64 C:\Users\jstanley\Anaconda3\lib\site-packages\pandas\io\excel.py in read_excel(io, sheetname, header, skiprows, skip_footer, index_col, names, parse_cols, parse_dates, date_parser, na_values, thousands, convert_float, has_index_names, converters, dtype, true_values, false_values, engine, squeeze, **kwds) 201 202 if not isinstance(io, ExcelFile): --> 203 io = ExcelFile(io, engine=engine) 204 205 return io._parse_excel( C:\Users\jstanley\Anaconda3\lib\site-packages\pandas\io\excel.py in __init__(self, io, **kwds) 258 self.book = xlrd.open_workbook(file_contents=data) 259 elif isinstance(io, compat.string_types): --> 260 self.book = xlrd.open_workbook(io) 261 else: 262 raise ValueError('Must explicitly set engine if not passing in' C:\Users\jstanley\Anaconda3\lib\site-packages\xlrd\__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows) C:\Users\jstanley\Anaconda3\lib\site-packages\xlrd\book.py in open_workbook_xls(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows) 89 t1 = time.clock() 90 bk.load_time_stage_1 = t1 - t0 ---> 91 biff_version = bk.getbof(XL_WORKBOOK_GLOBALS) 92 if not biff_version: 93 raise XLRDError("Can't determine file's BIFF version") C:\Users\jstanley\Anaconda3\lib\site-packages\xlrd\book.py in getbof(self, rqd_stream) 1228 elif rc == XL_NAME: 1229 self.handle_name(data) -> 1230 elif rc == XL_PALETTE: 1231 self.handle_palette(data) 1232 elif rc == XL_STYLE: C:\Users\jstanley\Anaconda3\lib\site-packages\xlrd\book.py in bof_error(msg) 1222 elif rc == XL_SHEETSOFFSET: 1223 self.handle_sheetsoffset(data) -> 1224 elif rc == XL_SHEETHDR: 1225 self.handle_sheethdr(data) 1226 elif rc == XL_SUPBOOK: 

似乎有一些Excel文件和XLRD的问题,而且很难分辨你正在面对的是什么。 你下载的文件是? 或者也许是一个旧文件? 腐败以看似随意的方式潜入Excel文件。

这个问题可能有帮助 。 另外,看看这个页面的其他想法。

最好的解决scheme似乎是打开Excel中的文件,然后将其另存为另一种格式(有时甚至只是一个新的.xlsx文件)。 手动,不雅,烦人。 但我不得不做了几次,它的工作。