mercredi 16 décembre 2020

How to check if a file is in a specific folder?

I have the following structure:

root
   |_ Audi
         |_file1.txt
         |_file2.txt

   |_ Mercedes
         |_file1.txt
         |_file2.txt 

I want to create a function that checks wether a file is in Audi or Mercedes.

  1. If the files are in `Audi' process.....
  2. If the files are in Mercedes process..

This is my code:

root = r'C:\data\desktop\my_folder\my_cars'

def move_to_db (path):
    ls_mts_raw = [] 
    for file in os.listdir(path):
        if file.endswith('.csv'):
            file_path = os.path.join(path, file)

move_to_db(root)

This is what I have untill now but I got stuck.....

Aucun commentaire:

Enregistrer un commentaire