Google-drive – How to unzip a .zip file on Google Drive

google-appsgoogle-colabgoogle-drivepython

I have a zip file of about 5GB on my Desktop. I am using Mac 10.12.6. I was able to upload this zip file to Google Drive and I could see it there but I could not unzip it in Google Drive to see the contents. It started to unzip, but after a couple of hours it terminated with an error indicating failure to unzip because of an error in the file itself:

Screenshot showing preview error

I have no problem unzipping it on the Desktop just by clicking on the file. Unzipping it I could see all contents so I assume that there is no error in the file itself, but rather with Google Drive. I've tried unsuccessfully to unzip on Google Drive using Zip extractor or just by clicking on the zip file (see image).

Best Answer

Have a look at Google Colab: https://colab.research.google.com/ It allows you to run Linux commands on your Google Drive.

To connect to your Google Drive, create a new Python 3 notebook. Then copy and paste the following code into the notebook, and then execute the cell (click on the play button or use shift-enter):

from google.colab import drive
drive.mount('/content/drive')

The output might ask for authorization and provide a URL. If so, point your browser to that URL to obtain an authorization code. Copy the authorization code back into your Google Colab notebook.

Finally, unzip your file by executing the following command:

!unzip -uq "drive/My Drive/PATH_TO_ZIP" -d "drive/My Drive/PATH_TO_OUTPUT"

The u stands for update and the q stands for quiet - the latter is a good idea because massive output can sometimes cause your Google Colab notebook to crash.