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.

Leave a Comment

tech