python xlrd不支持的格式,或损坏的文件。 [英] python xlrd unsupported format, or corrupt file.

查看:8282
本文介绍了python xlrd不支持的格式,或损坏的文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

import xlrd
wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls")
sh = wb.sheet_by_index(0)
print sh.cell(0,0).value

错误:

Traceback (most recent call last):
File "Z:\Wilson\tradedStockStatus.py", line 18, in <module>
wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls")
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 429, in open_workbook
biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1545, in getbof
bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1539, in bof_error
raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
found '<table r'"

该文件似乎没有被破坏或者不同的格式
任何帮助找到问题的根源将是巨大的。

The file doesn't seem to be corrupted or of a different format. Anything to help find the source of the issue would be great.

推荐答案

你说:


该文件似乎没有被破坏或格式不同。

The file doesn't seem to be corrupted or of a different format.

但是,如错误消息所示,文件的前8个字节为'< table r' ...即绝对不是Excel .xls 格式,使用文本编辑器(例如记事本)打开它,不会对(不正确的) .xls发出任何通知扩展,看看自己。

However as the error message says, the first 8 bytes of the file are '<table r' ... that is definitely not Excel .xls format. Open it with a text editor (e.g. Notepad) that won't take any notice of the (incorrect) .xls extension and see for yourself.

这篇关于python xlrd不支持的格式,或损坏的文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆