简体   繁体   English

检测损坏的xlsx文件(zip zith更改扩展名)大熊猫

[英]Detect corrupt xlsx file (zip zith changed extension) pandas

I am doing a small xlsx file checker, I need to implement a file corruption check. 我正在做一个小的xlsx文件检查器,我需要实现文件损坏检查。 I have the following code 我有以下代码

try:
    check_file = pandas.ExcelFile(input_excel)
except IOError: sys.exit("Unsupported format, or corrupt file")

It throws an exception for all kind of files with changed extension, except of archives. 对于所有扩展名已更改的文件(存档除外),它将引发异常。 So my question is, how can I detect archives with extension changed to an xlsx and throw an exception on them. 所以我的问题是,如何检测扩展名更改为xlsx的存档并在其上引发异常。 I am working with Python 3.6, pandas and numpy 我正在使用Python 3.6,pandas和numpy

实际上,问题出在异常类型上,我将其更改为更通用的Exception类型的异常,现在它可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 xlsxwriter创建的损坏的xlsx文件 - Corrupt xlsx file created by xlsxwriter 熊猫:将.xlsx文件转换为.csv会生成一个zip文件 - Pandas: converting .xlsx file to .csv results in a zip file 为什么Pandas打开.xls文件扩展名比.xlsx快 - Why does Pandas open .xls file extension faster than .xlsx 无法使用Pandas或openpyxl在任何.xlsx文件的单元格中检测到EUR - Unable to detect EUR in a cell of any .xlsx file, using pandas or openpyxl 将多个pandas数据帧转换为xlsx后如何压缩(单个zip文件)? - how to zip (single zip file) multiple pandas dataframes after converting it to xlsx? 数据丢失,使用熊猫在具有多个工作表的.xlsx文件中更改格式,同时在现有的.xlsx文件中添加新工作表时使用openpyxl - Data missing, format changed in .xlsx file having multiple sheets using pandas, openpyxl while adding new sheet in existing .xlsx file 用于检查zip文件是否已损坏的Python脚本 - Python script to check if a zip file is corrupt 使用xlsx writer进行条件格式化会生成带有“ text:contains”的损坏文件 - Conditional formatting with xlsx writer generates corrupt file with “text:containing” 无法使用 pandas 读取 xlsx 文件 - Cant read xlsx file with pandas 在熊猫中打开损坏的CSV文件的策略 - Strategy to open a corrupt csv file in pandas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM