How To Extract Column Value From Excel Using Python

You may have some Excel files from which you wanted to extract certain column's value. In this post , we will see how to extract or get values from column of Excel .xlsx file using Python


Extract Column Value From XLSX Excel

To extract the values from column using python , we need following libraries. Make sure to install them
  • pandas
  • openpyxl
Now we need an excel file with extension .xlsx. I am taking a sample xlsx file having data as


Now if we want to extract data from certain column , for example from Email , then we need to code
import pandas as pd
import numpy as np
filename=input("Enter File Name : ")
columnname=input("Enter Column Name : ")
df = pd.read_excel(filename)[[columnname]]
print(df)


This code will ask users to enter the filename & column name. Then it will show the data of the column entered. Please note that this code will not work for excel file having multiple sheets.