Jan-07-2020, 01:37 PM
Hi,
I want to read file given a partial file name:
the file structure is D:\PythonCodes -->\InputFiles\KYLJHQ_*\sub_folder/InputCSV.csv. I uae above code but it giving error:
TypeError: expected str, bytes or os.PathLike object, not list
I want to read file given a partial file name:
1 2 3 4 5 6 7 8 9 10 11 |
import glob my_dir = 'D:\PythonCodes' #post_fix = ['\InputFiles\KYLJHQ_20191215\sub_folder/InputCSV.csv','\InputFiles\KYLJHQ_20191215\sub_folder/InputCSV2.csv'] post_fix = [ '\InputFiles\KYLJHQ_*\sub_folder/InputCSV.csv' , '\InputFiles\KYLJHQ_*\sub_folder/InputCSV2.csv' ] for i in range ( len (post_fix)): full_path = glob.glob(my_dir + str (post_fix[i])) tmp_file = open (full_path, 'r' ) tmp_data = tmp.readlines() print (tmp_data) |
TypeError: expected str, bytes or os.PathLike object, not list