Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created May 12, 2022 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harendra21/fffacccacdecc8faa6ffbeb03ce6ee86 to your computer and use it in GitHub Desktop.
Save harendra21/fffacccacdecc8faa6ffbeb03ce6ee86 to your computer and use it in GitHub Desktop.
import xlrd
import sys
class ExcelToList():
def __init__(self, file, sheet):
self.file = file
self.sheet = sheet
def convert(self):
converted_list = []
inputexcel = xlrd.open_workbook(self.file)
inputsheet = inputexcel.sheet_by_name(self.sheet)
numberofrows = inputsheet.nrows
numberofcols = inputsheet.ncols
start_row,start_col = 0,0
for current_row in range(start_row,numberofrows):
currentlist = []
for current_col in range(start_col,numberofcols):
currentlist.append(inputsheet.cell(current_row,current_col).value)
converted_list.append(currentlist)
return converted_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment