file download from google drive to colaboratory

后端 未结 7 2147
遇见更好的自我
遇见更好的自我 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 12:53

    I recommend you use Pydrive to download your file from google drive. I download 500MB dataset for 5s. 1. install Pydrive

    !pip install PyDrive
    

    2. OAouth

    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    
    gauth = GoogleAuth()
    gauth.LocalWebserverAuth()
    
    drive = GoogleDrive(gauth)
    

    3. code for download file from google drive

    fileId = drive.CreateFile({'id': 'DRIVE_FILE_ID'}) #DRIVE_FILE_ID is file id example: 1iytA1n2z4go3uVCwE_vIKouTKyIDjEq
    print fileId['title']  # UMNIST.zip
    fileId.GetContentFile('UMNIST.zip')  # Save Drive file as a local file
    

    Cheer Mo Jihad

提交回复
热议问题