Fundamentals 4 min read

How to Add a Real-Time Progress Bar to Your Python Excel Merge Script

This tutorial shows how to merge multiple Excel files using pandas in Python and enhance the process with a live progress bar by integrating the tqdm library, complete with code examples and visual results.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Add a Real-Time Progress Bar to Your Python Excel Merge Script

1. Introduction

A few days ago, a question was posted in a Python community about adding a progress bar to a script that merges Excel files, as shown in the image below.

The original code reads all Excel files from a directory, concatenates them with pandas, and writes the combined result to a new file.

import os
import pandas as pd
file_list = os.listdir(r"F:\123")
data_list = []
for file in file_list:
    data = pd.read_excel(r"F:\123\\" + file)
    data_list.append(data)
result = pd.concat(data_list)
result.to_excel(r"F:\123\合并表格.xlsx", index=False)

2. Implementation

One contributor suggested using the tqdm library to display a progress bar. The following modified script incorporates tqdm and prints a completion message.

import os
import pandas as pd
from tqdm import tqdm
file_list = os.listdir(r"F:\123")
data_list = []
for file in tqdm(file_list):
    data = pd.read_excel(r"F:\123\\" + file)
    data_list.append(data)
result = pd.concat(data_list)
result.to_excel(r"F:\123\合并表格.xlsx", index=False)
print('全部表格合并完成')

Running the script produces the expected merged file, as shown below.

Some community members later tweaked the output to make it look more polished.

3. Conclusion

This article demonstrated how to solve the problem of adding a progress bar to a Python script that merges Excel files, providing clear explanations and complete code that readers can adapt for their own data‑processing tasks.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythonpandasprogress bartqdmdata-processing
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.