I am using is_zipfile
to check if it is a zipfile before extracting it. But the method returns True on excel file from a StringIO object. I am using Python 2.7. Does anyone know how to fix this? Is it reliable to use is_zipfiile
? Thanks.
Python's zipfile is a standard library module intended to manipulate ZIP files. This file format is a widely adopted industry standard when it comes to archiving and compressing digital data. You can use it to package together several related files.
Quoting from the Microsoft's XLSX Structure overview doc,
Workbook data is contained in a ZIP package conforming to the Open Packaging Conventions
So, .xlsx
files are actually zip files only. If you want not to consider them as a zip file, you may have to exclude with an if condition like this
if os.path.splitext(filename)[1] != ".xlsx" and zipfile.is_file(filename):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With