First, import the libraries that work with files:
from os import listdir
from os.path import isfile, join, exists
A helper function to read only files from a directory:
def get_files(path):
    for file in listdir(path):
        full_path = join(path, file)
        if isfile(full_path):
  ...