'How to combined these two together

So I wrote a code that take name and links from a csv file and creates two separate list of both. The name list is used to create folders by the name of list items and links list (they are basically google drive id to download .jpg present in them) is used to download file from the given links.

    import os
    import csv
    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    gauth = GoogleAuth()
    drive = GoogleDrive(gauth)
    with open('download_links.csv', encoding= "utf-8-sig") as csvfile:
     reader = csv.DictReader(csvfile)
     count = 0
     folders = []
     filename =[]
     for row in reader:
      count = count + 1
      folders.append(row["id"])
      filename.append(row['file'])
     for folder,filename in zip(folders,filename):
        file_list = drive.ListFile({'q' : f"'{folder}' in parents and trashed=false"}).GetList()
        os.makedirs(file)
        for index, file in enumerate(file_list):
            file.GetContentFile(file['title'])
    
    

How can I store the downloaded files in the folders which are created? Or can you suggest me a better way to solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source