Unzipping tar.7z files in google collab notebook


(Tabish Bashir) #1

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!


#2

@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!


(Arnav) #3

@Vivek10 This worked for me.

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


#4


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


(Arnav) #5

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.


(Aldrin) #6

@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.


(Duong Bui) #7

@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