How to unzip a folder in google colab?

Viewed 18796

I am trying to make an image classification task in Colab but after importing the dataset from the kaggle, the data comes in zip format. And when unzipped, the dataset is not giving a folder but giving a list of images. How can I get a folder outta it?

2 Answers

If you are using colab you can just use a ! to send the kernel a bash command.

This means that something like this in a new cell should do the trick:

!unzip my_data.zip -d my_data

if I have downloaded a zip file in drive via Colab like this

!wget 'http://nlp.stanford.edu/data/glove.840B.300d.zip' 

it will go by default to '/content'

then I need to unzip like this and bring in my destination folder -d

!unzip '/content/glove.840B.300d.zip' -d '/content/drive/My Drive/data'

'/content/drive/My Drive/data' ==> destination folder within drive

remember whatever is in '/content' will be removed once you shut down the system or go offline, to save it permanently within drive, give path like '/content/drive/My Drive/data'

Related