Skip to content

Instantly share code, notes, and snippets.

Last active July 20, 2019 20:14
What would you like to do?
# 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 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.
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
# List .txt files in the root.
# Search query reference:
listed = drive.ListFile({'q': "title contains '.txt'"}).GetList()
for file in listed:
print('title {}, id {}'.format(file['title'], file['id']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment