简体   繁体   中英

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. 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. I am working with Python 3.6, pandas and numpy

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM