Unzipping tar.7z files in google collab notebook

If anyone is having problems in unzipping tar.7z files downloaded from the kaggle competitions in your google collab notebook follow this link https://www.quora.com/How-do-I-extract-a-7-Zip-file-using-the-7-Zip-portable-version
Check the first answer!

1 Like

@tabish Could you give more steps or some screenshots of how you unzipped tar.7z in google colab notebook? I tried following the quora answer but I’m getting error as Permission denied. Plz Help me out. Thank you!

@Vivek10 This worked for me.

!apt-get install p7zip-full
!p7zip -d file_name.tar.7z
!tar -xvf file_name.tar

8 Likes


I am trying to use Kaggle’s Amazon from Space dataset. I facing trouble. Kindly help me out.

1 Like

p7zip can’t find train-jpg.tar.7z because it’s not in the working directory. When you use the kaggle cli, it downloads the competition files inside a hidden folder.
import os
os.chdir('.kaggle/competitions/planet-understanding-the-amazon-from-space/')
This or something similar should work.
Try !ls -a to see all files in the current directory.

@keratin’s answers worked for me but it doesn’t have to do with kaggle cli hiding files.

You need to change to the directory where you downloaded the files and cd doesn’t seem to actually move directories in Colab. If you use os.chdir you can change to the right directory and then run the tar commands shared by keratin.

@Vivek10

Try this:

!pip install pyunpack
!pip install patool

from pyunpack import Archive
Archive(‘file_name.tar.7z’).extractall(‘path/to/’)
!tar -xvf file_name.tar

1 Like

Hi, can anyone tell me how to create rar or zip file in google drive from google colab. I couldn’t find a method that works, please help me out

How can I unzip a File that contains space? like “Sample File.zip”

!tar -xvf “Sample File.zip”

Above command is not working. :frowning:

Muchas gracias por la ayuda, me sirvió de mucho.