How do I make a progress bar for loading pandas DataFrame from a large xlsx file?

The following is a one-liner solution utilizing tqdm: import pandas as pd from tqdm import tqdm df = pd.concat([chunk for chunk in tqdm(pd.read_csv(file_name, chunksize=1000), desc=”Loading data”)]) If you know the total lines to be loaded, you can add that information with the parameter total to the tqdm fuction, resulting in a percentage output.

Converting docx to pdf with pure python (on linux, without libreoffice)

The PythonAnywhere help pages offer information on working with PDF files here: https://help.pythonanywhere.com/pages/PDF Summary: PythonAnywhere has a number of Python packages for PDF manipulation installed, and one of them may do what you want. However, shelling out to abiword seems easiest to me. The shell command abiword –to=pdf filetoconvert.docx will convert the docx file to … Read more

How do you make an installer for your python program?

Regarding Installer Program (for windows). I think what you are looking for is InstallForge. This is a tool that you can use to build your own installation wizard. This website pythonguis is a tutorial for PyInstaller and InstallForge. You can skip the PyInstaller part and go towards the middle to view the InstallForge tutorial if … Read more

How to Copy Files Fast

The fastest version w/o overoptimizing the code I’ve got with the following code: class CTError(Exception): def __init__(self, errors): self.errors = errors try: O_BINARY = os.O_BINARY except: O_BINARY = 0 READ_FLAGS = os.O_RDONLY | O_BINARY WRITE_FLAGS = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | O_BINARY BUFFER_SIZE = 128*1024 def copyfile(src, dst): try: fin = os.open(src, READ_FLAGS) stat … Read more

Save an IPython notebook programmatically from within itself?

I am taking @Taar’s comment and making it an actual answer since it worked for the original person who asked the question and for myself. from IPython.display import display, Javascript display(Javascript(‘IPython.notebook.save_checkpoint();’)) This will create checkpoints – same thing as CTRL-s. Note: in Jupyter, CTRL-s triggers an async process and the file save is actually completed … Read more

extracting data from typing types

Checking if a variable conforms to a typing object To check if string_list conforms to string_list_class, you can use the typeguard type checking library. from typeguard import check_type try: check_type(‘string_list’, string_list, string_list_class) print(“string_list conforms to string_list_class”) except TypeError: print(“string_list does not conform to string_list_class”) Checking the generic type of a typing object To check if … Read more

error code: 521