Python 3 Pandas Library Script to Merge Multiple XLSX Excel Files Full Project For Beginners

Python 3 Pandas Library Script to Merge Multiple XLSX Excel Files Full Project For Beginners

 

Welcome folks today in this post we will be merging multiple xlsx excel files using pandas library in python. All the full source code of the application is given below.

 

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install pandas

 

After installing it make an app.py file and copy paste the following code

 

app.py

 

# importing the module 
import pandas 

# reading the files 
f1 = pandas.read_excel("registration details.xlsx") 
f2 = pandas.read_excel("exam results.xlsx") 

# merging the files 
f3 = f1[["REGISTRATION NO", 
        "STUDENT EMAIL ID "]].merge(f2[["REGISTRATION NO", 
                                        "Name", "Marks Obtained", 
                                        "Percentage"]], 
                                    on = "REGISTRATION NO", 
                                    how = "left") 

# creating a new file 
f3.to_excel("Results.xlsx", index = False)

 

 

Now in order to run this python script app.py you need to type the below command

READ  Python Tkinter GUI Scrollbar Widget in Both Horizontal and Vertical Directions to Load Content Full Project For Beginners

 

python app.py

 

We have the below two xlsx excel files that needs to be merged which are shown as follows

 

 

 

 

 

 

Leave a Reply