I have a GCP project and there is a Jupiter notebook which is to read files from G Drive.
def search_file(request = None):
try:
service = build('drive', 'v3', credentials=creds)
# Call the Drive v3 API
results = service.files().list(
pageSize=1, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])
if not items:
print('No files found.')
return
print('Files:')
for item in items:
print(u'{0} ({1})'.format(item['name'], item['id']))
except HttpError as error:
print(f'An error occurred: {error}')
I'm using Google's quickstart to retrieve files from G Drive. The authentication and all works fine and the intended drive has just one file on it. But when I execute this search_file
method, I'm getting No Files found.
message. I'm trying to read one csv file which resides in G Drive. What I have missed or any other alternatives for this?