Effortless Python Progress Tracking Master File Writing with a Dynamic Progress Bar!

PHOTO EMBED

Sun Apr 07 2024 22:58:25 GMT+0000 (Coordinated Universal Time)

Saved by @amramroo ##python #coding #file #progress #progressbar

from tqdm import tqdm
from time import sleep

text = """
This is text 123
""" * 100

# repeate text 100 times

with open('out.txt', 'w') as f:
    bar = tqdm(total=len(text), unit='B', unit_scale=True)
    for c in text:
        f.write(c)
        bar.update(1)
        sleep(0.0005)

content_copyCOPY