read google drive file in colab code example

Example 1: connect google drive to colab

from google.colab import drive
drive.mount("/content/gdrive")

Example 2: colab mount drive

from google.colab import drive
drive.mount('/content/drive')

#Optional: move to the desired location:
%cd drive/My Drive/DIRECTORY_IN_YOUR_DRIVE

Example 3: download google drive file colab

!gdown --id yourFileIdHere

Example 4: read file from google drive colab

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

Tags:

Go Example