Jan-07-2020, 04:56 PM
You give a list to open in line 9.
Some point you don't need glob as you construct a full path here,and use join to join paths.
So if put it together and use also code from Larz.
Some point you don't need glob as you construct a full path here,and use join to join paths.
So if put it together and use also code from Larz.
from os.path import join def read_file(filename): with open(filename) as fp: for line in fp: print(line.strip()) # No \ singel in path,eg use raw string my_dir = r'D:\PythonCodes' post_fix = ['InputFiles\KYLJHQ_*\sub_folder\InputCSV.csv', 'InputFiles\KYLJHQ_*\sub_folder\InputCSV2.csv'] full_path = [] for r_path in post_fix: full_path.append(join(my_dir, r_path)) # Now read both files for path in full_path: read_file(path)