Progress bar python

Tqdm is a great and easy progress bar for python. Here are some examples: 

Iterating through lists:

from tqdm import tqdm

a_list = [1,2,3,4,5]

for i in tqdm(a_list):
    print(i)

You can use it on generators:

from tqdm import tqdm

for i in tqdm(range(10)):
    print(i)

And even iterating through files:

import csv
from tqdm import tqdm

with open('names.csv', newline='', encoding='utf-8') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in tqdm(reader):
        print(
            row['first_name'],
            row['last_name']
        )
SNAPPED!

SNAPPED!

Comments

Popular posts from this blog

Append to a json file python

Setup Mailhog mail server on Ubuntu