The one that displays the progress bar in Python

It takes a lot of time to preprocess data and analyze it, and it's hard not knowing when it will end.

Hard

I want to display the progress bar

[===>  ]50% I want this.

Had made

https://gist.github.com/wassen/3f559de866415472b9b2 I made. Analysis over there. I've noticed that there is already this, but it's too late.

How to use

Part 1

Create an instance by inserting the list you want to turn or whatever, and call display_progressbar in the for statement.

sample1.py


from ProgressBar import ProgressBar as pb
import time

list1 = "I love you"
list2 = range(3)
list3 = [0,1]

pb1 = pb(list1,list2,list3)
for _ in list1:
	for _ in list2:
		for _ in list3:
			time.sleep(0.1)
			pb1.display_progressbar()

Part 2

Create an instance in the same way and have the method return the list.

sample2.py


#Same as above

pb2 = pb(list1, list2, list3)
for _ in pb2.generator(0):
	for _ in pb2.generator(1):
		for _ in pb2.generator(2):
			time.sleep(0.1)

Part 3

Just wrap the list without creating an instance. It's the easiest, but the drawback is that you can only see the rough progress.

sample3.py


#Same as above

for _ in pb.single_generator(list1):
	for _ in list2:
		for _ in list3:
			time.sleep(0.1)

Notes and miscellaneous feelings

-Instance initialization can be done with the length of the list instead of the list, but there is a bug when using the second. So the usage is unknown -You can explicitly specify the index when calling display_progressbar. It's like display_progressbar (i, j, k). The usage is unknown ・ I want to be able to add a list in the middle of a for statement when there is a list in the list. -You can add a list from the middle of the add method, but adding it in the middle of the for statement causes a bug. -Note that the elapsed time is measured when the instance is initialized. ・ I chose a color that seems to be kind to the eyes. ・ If you have any problems or suggestions for improvement, please do not hesitate to contact us.

reference

Thank you very much. http://www.yunabe.jp/docs/terminal_progress_bar.html

Recommended Posts

The one that displays the progress bar in Python
[Python] A progress bar on the terminal
One liner that outputs multiplication tables in Python
One liner in Python
Make progress of dd visible in the progress bar
I want to display the progress in Python!
Download the file while viewing the progress in Python 3.x
One liner that outputs 1000000 digits of pi in Python
Modules that may go through the shell in Python
Fizzbuzz in Python (in one line)
Download the file in Python
Find the difference in Python
DMD in Python one dimension
[Python] Adjusting the color bar
bar chart race in python
What to do if the progress bar is not displayed in tqdm of python
The story that `while queue` did not work in python
Make python segfault in one line
Python in the browser: Brython's recommendation
Save the binary file in Python
Hit the Sesami API in Python
Get the desktop path in Python
Get the script path in Python
In the python command python points to python3.8
Implement the Singleton pattern in Python
Hit the web API in Python
I wrote the queue in Python
Examine the object's class in python
Get the desktop path in Python
Get the host name in Python
Access the Twitter API in Python
The first step in Python Matplotlib
I wrote the stack in Python
Master the weakref module in Python
How is the progress? Let's get on with the boom ?? in Python
Play a sound in Python assuming that the keyboard is a piano keyboard
Real-time display of server-side processing progress in the browser (implementation of progress bar)
Movement that changes direction in the coordinate system I tried Python 3
How to judge that the cross key is input in Python3
A function that measures the processing time of a method in python
The story that 2D list replacement did not work in python
Released erajp that displays date time in Japanese calendar format in Python
"The one that blocks all Twitter accounts in the database" created by beginners of Python learning day
The story of creating a bot that displays active members in a specific channel of slack with python
Handle multiple python versions in one jupyter
How to display the progress bar (tqdm)
Learn the design pattern "Prototype" in Python
Learn the design pattern "Builder" in Python
[python] Move files that meet the conditions
CGI server (1) python edition in one line
Try using the Wunderlist API in Python
Check the behavior of destructor in Python
Implemented in python after understanding the phenomenon that various probability distributions occur
Learn the design pattern "Flyweight" in Python
Try using the Kraken API in Python
Learn the design pattern "Observer" in Python
Learn the design pattern "Memento" in Python
Learn the design pattern "Proxy" in Python
Write the test in a python docstring
Learn the design pattern "Command" in Python
OR the List in Python (zip function)