Google Drive API in Python | List Files and Folders in a Google Drive Folder

preview_player
Показать описание
In this Google Drive API in Python tutorial, I will be covering how to use Google Drive API to list files and folders in a Google Drive folder.

Buy Me a Coffee? Your support is much appreciated!
----------------------------------------------------------------------------------------------------------------
Venmo: @Jie-Jenn

Support my channel so I can continue making free contents
---------------------------------------------------------------------------------------------------------------

#GoogleDriveAPI #ListFiles #ListFolders
Рекомендации по теме
Комментарии
Автор

In the while loop, I think you forgot to add the pageToken variable to the list function. Without this you get an infinite loop if there are more than 100 files in the foder. response = service.files().list(q=query,

GoodeMovies
Автор

I successfully reached the end of the tutorial with no problems. I want to be able to select the id of a document. How can i do that?

Himosaybian
Автор

You are amazing, this playlist really helped me out!

mmokhles
Автор

Jie, What is in the json file and from where you got that file?

onlyzeroandone
Автор

if i want to loop through subfolders and read the googlesheet within them, how do i go about this? thanks!

dpdhync
Автор

Thanks mate! It's Work to me! Keep it up!
I have question let's say I have thousands of data files, If I use the terminal as the output it will take some time, To make it easier is there a way to directly convert the output to csv or excel or google sheets?

As in the Google API (General) playlist in the first video about Access Google API Directory

junakarta
Автор

Inside "while" you should include pageToken as an extra parameter to get the "next page".
Otherwise, if the folder has a large number of files, while command will be in looping.
...
while nextPageToken:
response = service.files().list(q=query,
files.extend(response.get('files', []))
nextPageToken =
...

marcoskunyosi
Автор

Thanks for efforts:
I have one doubt as I am getting this error
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1205, in send
return self._sslobj.write(data)
TimeoutError: The write operation timed out

for uploading large files

ambarpatil
Автор

Hi! Thanks for lessons!! I have a question: a friend sent me a link to his folder. I see the files in the browser, but the script does not. When I open one of the files, then the script starts to see it. The script starts seeing files after I interact with them in the browser.
What could be the problem?

denisalexandrov
Автор

Thank you for this. I'm on the "while NextPageToken:" bit and it has been running for a really long time, like 32 hours so far. I'll admit the folder I'm searching has 322 excel files (some of them large), and 2 empty folders. Is the issue that there are folders in there? I'm wondering why it is taking so long and if it will ever finish!

christinavanciu
Автор

This is working great with My Drive. But I'm trying to download files from a shared folder on google drive - which returns an empty data frame. Any advice on how I would be able to fix this?

alfredingram
Автор

It not working. It show everytime Google module not found. I have to download lib in python but still same error so can u tell me what i need to do?

panktisugandhi
Автор

Is it possible to get files from multiple folders of multiple users in one request?

nursgrata
Автор

Great video!!! How would you get a list of nested folders and files?

atsoamazed
Автор

What is the command to install the Google library? "from Google import Create_services"

leonardoalmeida
Автор

Hi. Please help me fix this error
response =
AttributeError: 'NoneType' object has no attribute 'file'

manhdt
Автор

I don't understand the mecanism of this api,
This is the code that I used and it retrieve to me all the files with all version of files.
response = (
gdrive.files()
.list(
pageToken=last_page_token,
spaces="appDataFolder",
orderBy="name, modifiedTime",
q='mimeType != and mimeType != and trashed=false',
fields="nextPageToken, "
"files("
" id, "
" mimeType, "
" name, "
" size, "
" md5Checksum, "
" modifiedTime, "
" parents, "
" headRevisionId)",
)
.execute()
)
I would like to retrieve only the last revision. Maybe an idea ?

ykaribou