3

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

  • so, you think that I read that I allowed to have free 15GB space, I allow to have less then 5Gb if it is zip? – Somebody Nov 9 '17 at 22:44
  • Unzipped is 7GB on disc and Zipped is 5.7Gb on disc and 134,810 items. Is it possible to put unzipped from Desktop directly to google Drive? – Somebody Nov 9 '17 at 23:41
  • Yes, I have all those files on my Desktop. Why is there problems just drop them in the right place in the Drive? I am wondering if this free space 15 GB is corrupted and if I pay money, I could upload? But I've already move from Dropbox to use the free space on google Drive... Maybe I should try to upload something smaller and see how it works. – Somebody Nov 10 '17 at 0:12
1

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.

1

You can write a simple python code to extract the zip-file directly in your Google Drive from Google Colab.

Note: For this code to work, you'll need to install a module named rarfile in Colab. You can do so by the following code snippet:

pip install rarfile

Without getting into the details of how it works, go ahead and copy the code snippet below into Google Colab and run the cell.

def unrar(dpath,xpath):
  for rar in os.listdir(dpath):
    filepath = os.path.join(dpath, rar)
    with rarfile.RarFile(filepath) as opened_rar:
      for f in opened_rar.infolist():
        print (f.filename, f.file_size)
        opened_rar.extractall(xpath)

unrar(dpath,xpath)

Here, dpath is the path directory where your .rar file is located. xpath is where you want to extract it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.