I couldn't make a list with these codes in python
import os
path = r'C:\Users\fabri\Downloads\arquivos'
extension = '.csv'
for root, dirs_list, files_list in os.walk(path):
for file_name in files_list:
if os.path.splitext(file_name)[-1] == extension:
file_name_path = os.path.join(root, file_name)
print(file_name_path)
CodePudding user response:
Use glob.glob()
with the recursive=True
option to get all the matching files in a folder and its subfolders.
from glob import glob
path = r'C:\Users\fabri\Downloads\arquivos'
file_list = glob.glob(os.path.join(path, '**/*.csv'), recursive=True)