This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
# List .txt files in the root. | |
# | |
# Search query reference: | |
# https://developers.google.com/drive/v2/web/search-parameters | |
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