How to read particular column in Excel using Python
In this article, we will learn to read a particular column in Excel using Python.
The module xlrd
can be used to work with excel files in Python. This can be installed using the command
pip install xlrd
import xlrd excel_file = xlrd.open_workbook('Students.xlsx') sheet = excel_file.sheet_by_index(0) data_0 = [] data_1 = [] # iterating along the length of the column for i in range(sheet.nrows): # reading data from 0th column data_0.append(sheet.cell(i, 0).value) # reading data from 1st column data_1.append(sheet.cell(i, 1).value) print(data_0) print(data_1)
Output:
['Name', 'ABEL', 'BINDU', 'CHRISTY', 'YOUSUF', 'KRISHNA'] ['Age', 20.0, 21.0, 20.0, 21.0, 20.0]
Subscribe
Login
Please login to comment
0 Discussion