-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtqdm_progress_bar.py
More file actions
26 lines (15 loc) · 1 KB
/
tqdm_progress_bar.py
File metadata and controls
26 lines (15 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""In this example, we will see how to code a progress bar for file upload using tqdm python module. Feel free to use it in your own way.
For more information, you may refer this docuentation - https://tqdm.github.io/
"""
from tqdm import tqdm # Importing tqdm module
from time import sleep # We are importing sleep() from time module to enter delay just for this example.
no_of_files = 5 # Example - 5 files to upload
""" Creating a TQDM object so that we can use it later to customize the progress bar. This line will loop through the given range i.e. number of files in this case """
obj = tqdm(range(no_of_files), unit = "File") #Unit can be descriptive as per case. For ex. here it is "File"
for i in obj: #iterating through object range to start the progress bar
obj.set_description(f'File uploading {i+1}')
sleep(1) # adding manual delay. This can be skipped for real example.
"""
#OUTPUT
File uploading 5:: 100%|██████████| 5/5 [00:05<00:00, 1.00s/File]
"""