Skip to content

Instantly share code, notes, and snippets.

@userddssilva
Created May 21, 2020 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save userddssilva/55fa4d83b39e3d71e9216b305984f342 to your computer and use it in GitHub Desktop.
Save userddssilva/55fa4d83b39e3d71e9216b305984f342 to your computer and use it in GitHub Desktop.
#@title Download Dataset to Google Colab { form-width: "800px" }
# e.g GOOGLE_DRIVE_FILE_URL: https://drive.google.com/open?id=1CZyDkHHjS8SUVBF7fBwoTAF6xSpLmD4P7
LinkFile = "https://drive.google.com/open?id=1ZKGI0xYnBWYpSf13fbmVTnIxBa6cTQyH" #@param {type:"string"}
# e.g GOOGLE_DRIVE_FILENAME_WITH_EXTENSION: Local History.csv
Filename = "codebench.zip" #@param {type:"string"}
Filename = Filename.replace(' ', '\ ')
# Install the PyDrive wrapper & import libraries.
# This only needs to be done once per notebook.
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive client.
# This only needs to be done once per notebook.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
# Download a file based on its file ID.
#
# A file ID looks like: laggVyWshwcyP6kEI-y_W3P8D26sz
file_id = LinkFile.split('=')[-1]
downloaded = drive.CreateFile({'id': file_id})
downloaded.GetContentFile(Filename)
@userddssilva
Copy link
Author

script to downloading file of Google Drive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment