[已解决]报错:xlrd.compdoc.CompDocError: Workbook: size exceeds expected 17920 bytes; corrupt?
报错代码如下:
filePath='test.xls'
data=pd.read_excel(filePath)
print(data.head())
报错内容如下:
Traceback (most recent call last):
File "e:/PyCharm/Demo/TestFileDirectory/test.py", line 18, in <module>
data=pd.read_excel(filePath,data__only=True)
File "D:\Program Files\Python37\lib\site-packages\pandas\util\_decorators.py", line 208, in wrapper
return func(*args, **kwargs)
File "D:\Program Files\Python37\lib\site-packages\pandas\io\excel\_base.py", line 310, in read_excel
io = ExcelFile(io, engine=engine)
File "D:\Program Files\Python37\lib\site-packages\pandas\io\excel\_base.py", line 819, in __init__
self._reader = self._engines[engine](self._io)
File "D:\Program Files\Python37\lib\site-packages\pandas\io\excel\_xlrd.py", line 21, in __init__
super().__init__(filepath_or_buffer)
File "D:\Program Files\Python37\lib\site-packages\pandas\io\excel\_base.py", line 359, in __init__
self.book = self.load_workbook(filepath_or_buffer)
File "D:\Program Files\Python37\lib\site-packages\pandas\io\excel\_xlrd.py", line 36, in load_workbook
return open_workbook(filepath_or_buffer)
File "D:\Program Files\Python37\lib\site-packages\xlrd\__init__.py", line 157, in open_workbook
ragged_rows=ragged_rows,
File "D:\Program Files\Python37\lib\site-packages\xlrd\book.py", line 88, in open_workbook_xls
ragged_rows=ragged_rows,
File "D:\Program Files\Python37\lib\site-packages\xlrd\book.py", line 636, in biff2_8_load
cd.locate_named_stream(UNICODE_LITERAL(qname))
File "D:\Program Files\Python37\lib\site-packages\xlrd\compdoc.py", line 399, in locate_named_stream
d.tot_size, qname, d.DID+6)
File "D:\Program Files\Python37\lib\site-packages\xlrd\compdoc.py", line 434, in _locate_stream
% (qname, found_limit * sec_size)
xlrd.compdoc.CompDocError: Workbook: size exceeds expected 17920 bytes; corrupt?
已试用但未成功方案:
import xlrd
import pandas as pd
#方式一:
data=pd.read_excel(filePath)
print(data.head())
#方式二:
x1 = xlrd.open_workbook(filePath)
mySheet = x1.sheets()[0]
nrows = mySheet.nrows
print("row num:", nrows)
#方式三:
f = open(filePath, 'rb')
lines = f.readlines()
for line in lines:
line = line.decode('gbk').encode('utf8')
print (line)
最后的解决方案如下:
from win32com.client import Dispatch
filePath='test.xls'
xl = Dispatch('Excel.Application')
wb = xl.Workbooks.Open(filePath)
ws = wb.Worksheets(1)
info = ws.UsedRange
rows = info.Rows.Count
print (rows)
[已解决]报错:xlrd.compdoc.CompDocError: Workbook: size exceeds expected 17920 bytes; corrupt?的更多相关文章
- [已解决]报错: Error response from daemon: conflict
报错内容: Error response from daemon: conflict: unable to delete f5b6ef70d79b (must be forced) - image i ...
- [已解决]报错: Windows下Redis服务无法启动,错误 1067 进程意外终止解决方案
启动redis时出现的报错内容: 解决方法: 找到登录状态 如果是网络服务,直接双击此服务,修改为本地系统服务即可启动!
- [已解决]报错: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/mac/Ana
报错代码: pip3 install gerapy 报错内容: Could not install packages due to an EnvironmentError: [Errno 13] Pe ...
- [已解决]报错: Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
问题: windows下安装Redis第一次启动报错: [2368] 21 Apr 02:57:05.611 # Creating Server TCP listening socket 127.0. ...
- [已解决]报错JSONDecodeError
报错: 解决:
- [已解决]报错:ValueError: Expected 2D array, got scalar array instead
报错代码: new_x = 84610 pre_y = model.predict(new_x) print(pre_y) 报错结果: ValueError: Expected 2D array, g ...
- [已解决]报错:have mixed types. Specify dtype option on import or set low_memory=False
报错代码: import pandas as pd pd1 = pd.read_csv('D:/python34/program/wx_chat_single/qq_single.csv') 报错内容 ...
- [已解决]报错Could not install packages due to an EnvironmentError
安装OpenCV过程中出现错误 代码: pip-conda install -i https://pypi.douban.com/simple/ opencv-python 报错内容如下: Could ...
- [已解决]报错UnicodeDecodeError
输出报错: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 220: in 解决方案:将编码方式utf-8 修 ...
随机推荐
- 一些关于SEO优化的笔记
高级搜索指令: 双引号:“xxx” 代表完全匹配的搜索 减号:-(减号前面必须是空格,后面必须没有空格)代表搜索不包含减号后面的词的页面 filetype:用于搜索特定文件格式(百度支持的文件类型:P ...
- mapreduce实验
代码: public class WordCount { public static void main(String[] args) throws IOException, ClassNotFoun ...
- number框
因为系统的number框无法设置样式,所以休息无聊时写了一个简单的模拟number框的插件,效果不是很完善,有一些功能可能没注意到 // 简单的模拟number框插件 // 布局: // <di ...
- Oracle varchar2或char类型的byte和char的区别
那其中的BYTE和CHAR有什么区别呢 BYTE,用字节指定:VARCHAR2(10 BYTE).这能支持最多10字节的数据,在一个多字节字符集中,这可能只是两个字符.采用多字节字符集时,字节与字符并 ...
- java基础之轻松搞定反射
前言 java的名词太古怪.反射白话文解释,就是把一个字符串的类名,实例化,少了个new单词. 反射步骤 准备一个苹果类像这个样子. public class PingGuo { private St ...
- Redis面试题大全含答案
Redis面试题大全含答案 Redis面试题大全含答案 1.什么是Redis?答:Remote Dictionary Server(Redis)是一个开源的使用ANSI C语言编写.支持网络.可基于内 ...
- linux rsync 复制文件忽略文件夹
比如: /home/vagrant/test 目录下有 a,b,c 三个文件夹,只复制 c 文件夹下面的文件到/home/vagrant/test2 下 使用cp命令复制的时候,只能排除一个目录不被复 ...
- JavaSE---IO体系
1.BIO 1.1 Block IO,同步阻塞IO: 1.2 eg:java.io 包下的 InputStream . OutputStream. Writer.Reader... j ...
- Python中的try-finally
>>> try: ... raise KeyboardInterrupt ... finally: ... print('Goodbye, world!') ... Goodbye, ...
- 阿里云公共DNS正式发布支持IPv6的版本
在10月23日召开的GNTC 2019全球网络技术大会IPv6分论坛上,阿里云高级技术专家张先国宣布支持阿里公共DNS的IPv6版本正式发布,即阿里公共DNS在保持IPv4 稳定解析服务的基础上(An ...