Dec-14-2019, 02:37 PM
Hi,
I am trying to search a full path of the file given a root directory (this can vary), and postfix file name.
I am using the below code but I always get File does not exist ad list index out of range. and my full file path is empty.
I am trying to search a full path of the file given a root directory (this can vary), and postfix file name.
I am using the below code but I always get File does not exist ad list index out of range. and my full file path is empty.
#%% import glob import sys import os file1_name = "D:\Backupdata" post_fix = ["\PythonCodes\InputCSV1.csv"] try: full_path = (glob.glob(file1_name + str(post_fix)))[0] if (os.path.exists(full_path == True)): print("file exists") else: print("fail") except FileNotFoundError or IndexError: print("file does not exist")