I need to port some R code to Python and want to list all the files present in a directory which is shared with me. In R I can provide a Drive directory's ID to googledrive::drive_ls
as per the following:
ID_DIR <- "nprGPfKdhN_LZkyibY9UB43Mzm2D0sCv5"
drive_ls(path = as_id(ID_DIR), type = "spreadsheet")
...assuming we have a directory at the URL https://drive.google.com/drive/u/1/folders/nprGPfKdhN_LZkyibY9UB43Mzm2D0sCv5
the ID is nprGPfKdhN_LZkyibY9UB43Mzm2D0sCv5
. (I randomly generated the ID, so this doesn't actually exist.)
How can I list all the files present in a directory so as to later use these file IDs to pull in Google Sheets using Python's gspread
?
Is there a more direct way to do this using gspread
without listing the files beforehand?