Question

I have searched trough many answers on this site but none are working for me. I want to overwrite the print within this loop every time it loops:

for searchedfile in searchedfiles:
    print ("Searching Files:", searchedfile)
    with open(searchedfile) as f_in, open(outfilecamera, 'a') as f_out:
        f_out.writelines(searchedfile)
        f_out.writelines(ii)
        matched_lines = list(line for line in f_in if "timeout of" in line)          
        f_out.writelines(matched_lines)
        for line in searchedfile.split("\n"):
             if "Cycle " in line:
                 cycleno = line.split("#")[-1].split(".log")[0]
        file_counts.append((cycleno,len(matched_lines)))

I have tried various things including "\r" but i cannot seem to get it right.

Thanks

Was it helpful?

Solution

How about this?

sys.stdout.write("\rDoing thing %i" % i)
sys.stdout.flush()

Like mentioned in: Replace console output in Python

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top