1

i'm using a code to decompress an archive coming from a blob storage and this code is already functional for another archive that has 300mb, but while trying to decompress another one bigger than this, i've got this error:

"NotImplementedError: That compression method is not supported"
The last lines of error console show this :
/usr/local/lib/python3.8/zipfile.py in _get_decompressor(compress_type)
    718 
    719 def _get_decompressor(compress_type):
--> 720     _check_compression(compress_type)
    721     if compress_type == ZIP_STORED:
    722         return None

/usr/local/lib/python3.8/zipfile.py in _check_compression(compression)
    698                 "Compression requires the (missing) lzma module")
    699     else:
--> 700         raise NotImplementedError("That compression method is not supported")

And i'm using this code to this:

# mother folder
files = dbutils.fs.ls(dl_path)

for fi in sorted(files, reverse=True):
  zip_files = zipfile.ZipFile(f'/dbfs{dl_path}{fi.name}')
  print(zip_files.namelist())
  for f in zip_files.namelist():
    zip_files.extract(f, str(extract_path).replace('dbfs:', '/dbfs'))

I dont know why in one of archives this one works but the other one dont. I assume it might be about size? So i'm thinking about do a try: first code and except a second one? Idk, some one has tips?

JowOfBeco
  • 11
  • 2
  • Which line in your code is it failing at? – Red Aug 20 '21 at 14:17
  • " zip_files.extract(f, str(extract_path).replace('dbfs:', '/dbfs'))" This line. When doing extract, like this bigger zip i'm trying to extract is not supported but it did no clue about what, i think nothing unless size is different in case. – JowOfBeco Aug 20 '21 at 14:44

1 Answers1

0

There are many compression methods allowed in a zip file. It appears that that zip file uses a compression method not supported by the Python library.

Use the command-line unzip on the zip file that fails to list the contents. Do unzip -lv file.zip. It will list the compression methods used.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Yep, bash was my solution here. So i did this code : %sh unzip $path_zip -d extraction_path And got other modifications to get this code as generic as possible while thinking about paths. But thanks for your answer ! – JowOfBeco Aug 23 '21 at 19:24
  • So what was the compression method that Python didn't support? – Mark Adler Aug 23 '21 at 20:34