Below is the code
from glob import glob
PATH = "/home/someuser/projects/someproject"
EXT = "*.csv"
all_csv_files = [file
for path, subdir, files in os.walk(PATH)
for file in glob(os.path.join(path, EXT))]
That’s it !! While above code is written for searching csv files recursively in directory and subdirectory; it can be used to search for any file type. You just need to change the EXT. So say you want to find all the .css files, all you have to do is […]