Read Data from MS Excel (XLSX) File using Python

xlrd library

  1. Install xlrd library from the command line:
pip install xlrd
  1. Read data from MS Excel (XLSX) file:
import xlrd

workbook = xlrd.open_workbook('test.xlsx')
sheet = workbook.sheet_by_index(0)

data = [[sheet.cell_value(r, c) for c in range(sheet.ncols)] for r in range(sheet.nrows)]

print(data)

Leave a Comment

Cancel reply

Your email address will not be published.