5agado
5agado

Reputation: 2454

How to extract 7zip file from IBM Data Science Experience Notebook

Silly question, but being unable to install 7zip from the notebook, and not having access to the underling system, I am here stuck with different 7zip archives obtained via wget which I am not able to extract.

Also I would like to avoid the obvious option of downloading archives locally, and eventually upload data unzipped or in different formats, not really a process I can automatize easily.

Upvotes: 1

Views: 1702

Answers (2)

Akshay Vispute
Akshay Vispute

Reputation: 11

Tested and worked for me

#for windows users :
pip install --user pyunpack
pip install --user patool

#for ubuntu users :
sudo pip install pyunpack
sudo pip install patool

from pyunpack import Archive
Archive('YourFile.7z').extractall("your/path/")

Upvotes: 1

data_henrik
data_henrik

Reputation: 17156

Not tested, but an idea: DSX allows to install custom libraries. You could try to install py7zlib which is able to decompress 7zip archives:

!pip install --user py7zlib

An later something like

myfile=open(filename,"rb")
archive = py7zlib.Archive7z(myfile)
data = archive.getmember(archive.getnames()[0]).read()

Upvotes: 2

Related Questions