file download from google drive to colaboratory

后端 未结 7 2149
遇见更好的自我
遇见更好的自我 2021-02-05 12:22

I was trying to download file from my google drive to colaboratory.

file_id = \'1uBtlaggVyWshwcyP6kEI-y_W3P8D26sz\'

import io
from googleapiclient.http import M         


        
相关标签:
7条回答
  • 2021-02-05 13:10

    the easiest method to download a file from google drive to colabo notebook is via the colabo api:

    from google.colab import drive
    drive.mount('/content/gdrive')
    
    !cp '/content/gdrive/My Drive/<file_path_on_google_drive>' <filename_in_colabo>
    

    Remarks:

    1. By the drive.mount(), you can access any file on your google drive.
    2. 'My Drive' is equivalent 'Google Drive' on your local file system.
    3. The file_path is surrounded with single quotes as the standard directory below the mount point ('My Drive') has a space, and you might also have spaces in your path elsewhere anyway.
    4. Very useful to locate your file and get the file path is the file browser (activated by click on left arrow). It lets you click through your mounted folder structure and copy the file path, see image below.

    0 讨论(0)
提交回复
热议问题