[英]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.