I am trying to keep a watch on the log folder. If any new file is created then the file path must get returned. for that I have used the following code:
import glob
list_of_files_in_real_predicted = glob.iglob(r'logging\real_predicted\*')
latest_file_in_real_predicted = max(list_of_files_in_real_predicted, key=os.path.getctime)
print(latest_file_in_real_predicted)
The output returned is: logging\real_predicted\log935.csv
instead of: logging\real_predicted\log0.csv
Here is the snapshot of the folder and one can see the latest file created;
Please let me know what I can do to get the latest created file.