I'm new to pyDrive (and Python in general). I'm working on a personal project and I ran into an efficiency problem.
First, let me share you the code:
def initializeCSV(ID): # Id starts off as 'root' and then goes from there
folderNames = []
folderIDs = []
file_list = drive.ListFile({'q': "'{}' in parents and trashed=false".format(ID)}).GetList()
for file in file_list:
if file['mimeType'] == 'application/vnd.google-apps.folder':
folderIDs.append(file['id'])
folderNames.append(file['title'])
with open('Folders.csv', 'a+', newline='') as file:
writer = csv.writer(file)
for i in range(len(folderNames)):
writer.writerow([folderNames[i], folderIDs[i]])
for file in file_list:
initializeCSV(file['id'])
Basically, what I'm trying to do here is query the entire account and create a .csv file with the names and IDs of application/vnd.google-apps.folder
files. This file is going to be used later for other things I have in mind.
Now, the function works perfectly fine. But there's one problem, it takes like 3-4 minutes to query an account with around 50 folders inside. I was wondering if there was a faster or better way to do what I'm trying to do?
Thanks!