Search code examples
google-drive-apiuploaddatasetgoogle-colaboratory

Trouble in uploading a large file from google drive url to google colab


I need to upload a large file ( Sample File) to google colab. This file is located on a google drive account.

Consider these situation:

  1. My google drive is approximately full, so I could not upload it to my drive
  2. My connection speed is low and downloading this file and uploading it to google drive is a great challenge for me.

Also, I read some stackoverflow pages like: Import data into Google Colaboratory and these ones: Download File from URL to Google Drive using Google Colab in Python , Get Started: 3 Ways to Load CSV files into Colab and 7 ways to load external data into Google Colab. But non of them was useful for my case. I also tried !wget command but it could not download a google drive link.


Solution

  • Assume you have a shared google drive link like this one:

    shared link

    Then share it with another person:

    share via email

    Now, go to your google drive and check Shared with me:

    Share file in google drive

    Add shortcut to drive: Now this file has been added to google drive and it is accessible in colab.

    Finally, go to colab and run these commands:

    from google.colab import drive
    drive.mount('/content/drive')
    
    
    import os
    os.chdir("drive/My Drive/Weights/")
    

    And file is there!

    Uploaded file