How to unzip files from managed folder in dataiku

prasad
prasad Registered Posts: 2 ✭✭

I am getting error as :

NotImplementedError: That compression method is not supported

at zip_file.open(), even though code is able to list the filenames in zipped folder as you can see VBOX0001.vbo

Operating system used: Windows

Operating system used: Windows

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,090 Neuron

    Please post your code in a code block (the </> icon on the toolbar) so we can copy it to try to reproduce the issue. Please also post the full error trace in a code block so we can see the full error stack.

  • prasad
    prasad Registered Posts: 2 ✭✭
    input_folder = dataiku.Folder("GENZ_BRAZIL")
    output_folder = dataiku.Folder("GENZ_BRAZIL_Output")
    
    zip_file_name = '/GSW3614 PBT01580/3614-2023-06-30/VBOX0306.zip'
    
    with input_folder.get_download_stream(zip_file_name) as file_stream:
    f = io.BytesIO(file_stream.read())
    with zipfile.ZipFile(f) as zip_file:
    for file_name in zip_file.namelist():
    print(file_name)
    with zip_file.open(file_name) as extracted_file:
    output_folder.upload_stream(file_name, extracted_file) Error:

    VBOX0001.vbo
    ---------------------------------------------------------------------------
    NotImplementedError Traceback (most recent call last)
    Cell In[54], line 8
    6 for file_name in zip_file.namelist():
    7 print(file_name)
    ----> 8 with zip_file.open(file_name) as extracted_file:
    9 output_folder.upload_stream(file_name, extracted_file)

    File /opt/dataiku/code-env/lib/python3.9/zipfile.py:1580, in ZipFile.open(self, name, mode, pwd, force_zip64)
    1577 else:
    1578 pwd = None
    -> 1580 return ZipExtFile(zef_file, mode, zinfo, pwd, True)
    1581 except:
    1582 zef_file.close()

    File /opt/dataiku/code-env/lib/python3.9/zipfile.py:801, in ZipExtFile.__init__(self, fileobj, mode, zipinfo, pwd, close_fileobj)
    798 self._compress_left = zipinfo.compress_size
    799 self._left = zipinfo.file_size
    --> 801 self._decompressor = _get_decompressor(self._compress_type)
    803 self._eof = False
    804 self._readbuffer = b''

    File /opt/dataiku/code-env/lib/python3.9/zipfile.py:700, in _get_decompressor(compress_type)
    699 def _get_decompressor(compress_type):
    --> 700 _check_compression(compress_type)
    701 if compress_type == ZIP_STORED:
    702 return None

    File /opt/dataiku/code-env/lib/python3.9/zipfile.py:680, in _check_compression(compression)
    677 raise RuntimeError(
    678 "Compression requires the (missing) lzma module")
    679 else:
    --> 680 raise NotImplementedError("That compression method is not supported")

    NotImplementedError: That compression method is not supported

Setup Info
    Tags
      Help me…