i'm trying to run python script which already ran on test environment.
already checked if the path correct and if the file in it.
checked in shell that the file exist.
current code is :
# Open a file
path = 'C:\\Users\\tzahi.k\\Desktop\\netzer\\'
dirs = os.listdir( path )
fileslst = 
alertsCode = (some data)
# loop over to search the relative file
for file in dirs:
if "ALERTS" in file.upper() :
#open and modify the latest file
with open(fileslst[-1], 'rb') as csvfile:
csvReader = csv.reader(csvfile)
clean_rows = [row for row in csvReader if not any(alert in row for alert in alertsCode)]
IOError:error 2 no such file or directory:'file name'
os.listdir() lists the files relative to the directory.
You need to add the full directory path to the filename for it to be an absolute path again:
with open(os.path.join(path, fileslst[-1]), 'rb') as csvfile: