[已解决]报错: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 修 ...
随机推荐
- Sublime Text3怎样在Deepin中配置CTags插件
首先是要安装好Package Control,然后装插件CTags,这个时候在文件中右键已经能够出现Navigate to Definition菜单项了.然而,如果没有装CTags这个软件还是没用,所 ...
- C#socket客户端自己输入消息发送到服务端通信实现通信
一,服务端代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- SpringMVC学习(11):表单标签
本篇我们来学习Spring MVC表单标签的使用,借助于Spring MVC提供的表单标签可以让我们在视图上展示WebModel中的数据更加轻松. 一.首先我们先做一个简单了例子来对Spring MV ...
- 基于QRcode的带有文字+图片的二维码的Vue组件
1 <template> 2 <!-- 生成二维码开放接口: 3 二维码内容[通常为url] 4 二维码大小[限制为正方形] 二维码下方显示:文字 5 二维码中间显示:图片--> ...
- Alpha版本——展示博客【第二组】
成员简介 章豪 http://cnblogs.com/roar/ 角色: PM,后端 个人介绍: 努力学习开发的小菜鸡,管理小白,背锅组长 贡献: - 设计开发计划 - 跟踪项目进行 - 组织开组会 ...
- C语言实现Windows下获取IP和MAC地址。
C语言实现Windows下获取IP和MAC地址. #include <winsock2.h> #include <stdio.h> #include <stdlib.h& ...
- DNS安装配置主从
准备环境 关闭防火墙 挂载一下 更改配置文件 安装dns服务 更改配置文件 先复制保存一份
- 第二则java读取excel文件代码
// 得到上传文件的保存目录,将上传的文件存放于WEB-INF目录下,不允许外界直接访问,保证上传文件的安全 String savePath = this.getServletContext().ge ...
- Shell脚本并发及并发数的控制
https://www.jianshu.com/p/701952ffb755 正常情况下,Shell脚本是串行执行的,一条命令执行完才会执行接下来的命令.如下代码: # !/bin/bash for ...
- STM32点LED灯
一.建立项目模板 这里的user中重复引用了system_stm32f10x.c Output中选择Create HEXFile,并且可以选择输出路径. Listing中可以选择输出路径. 然后在C/ ...