alicec
alicec

Reputation: 59

How can I make the tqdm progress bar be printed less frequently in the log file?

I am using tqdm progress bar on an iterator of length more than 100000.

So it looks something like this:

from tqdm import tqdm

for _, i in tqdm(enumerate(range(100000)), total=100000):
    print(i)

Since it prints the progress bar 100000 times in the log file, it overwhelms and makes important information hard to find.

How can I make the tqdm progress bar be printed less frequently in the log file, say, every 10%?

Thank you!

Upvotes: 4

Views: 1197

Answers (1)

Jett Chen
Jett Chen

Reputation: 382

tqdm is not built for writing into the log file; however, you can still use a nested loop with the loop having the tqdm and the inner loop just being a simple for loop

for outer in tqdm(range(0,1e5,1e4)):
    for inner in range(1e4):
        print(outer+inner)

Upvotes: 3

Related Questions