I'm trying to save a file in a program while Python runs in the background. I made a while loop for "os" to try and find the Results file, and to keep checking until it exists. Before that (the try, except block), I made a short backup file code (I'm unsure if this is significant to my problem).
import os
import time
path = "D:\\DICOM\\Data\\"
try:
os.rename(path + "Results.csv", path + "Archive\\Results-Backup1.csv")
except FileNotFoundError:
print("")
except FileExistsError:
os.remove(path + "Archive\\Results-Backup1.csv")
os.rename(path + "Results.csv", path + "Archive\\Results-Backup1.csv")
path= path + "Results.csv"
k = str(os.path.isdir(path))
print(k)
while k== "False":
time.sleep(1)
k=str(os.path.isdir(path))
print("k is now TRUE")
I'm waiting for k to be True so I can continue with my code, but it's always False since os never recognizes the new path. Can anyone find any problems with my code?
Thank you in advanced very much :)