From 1ebff835161336eec412acf3b514ce4727a175a5 Mon Sep 17 00:00:00 2001 From: nitish-iiitd Date: Thu, 11 Oct 2018 23:54:46 +0530 Subject: [PATCH] Added ExcelToList Converter --- Excel_to_ListofList/ExcelToList.py | 22 +++++++++++++++++++++ Excel_to_ListofList/README.md | 9 +++++++++ Excel_to_ListofList/__init__.py | 0 Excel_to_ListofList/excel_to_list_usage.py | 6 ++++++ Excel_to_ListofList/input.xlsx | Bin 0 -> 5032 bytes 5 files changed, 37 insertions(+) create mode 100644 Excel_to_ListofList/ExcelToList.py create mode 100644 Excel_to_ListofList/README.md create mode 100644 Excel_to_ListofList/__init__.py create mode 100644 Excel_to_ListofList/excel_to_list_usage.py create mode 100644 Excel_to_ListofList/input.xlsx diff --git a/Excel_to_ListofList/ExcelToList.py b/Excel_to_ListofList/ExcelToList.py new file mode 100644 index 0000000..3f14167 --- /dev/null +++ b/Excel_to_ListofList/ExcelToList.py @@ -0,0 +1,22 @@ +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 \ No newline at end of file diff --git a/Excel_to_ListofList/README.md b/Excel_to_ListofList/README.md new file mode 100644 index 0000000..7aa89de --- /dev/null +++ b/Excel_to_ListofList/README.md @@ -0,0 +1,9 @@ +# Excel to Python List of List Converter +A simple tool which reads an excel file and any corresponding sheet, and converts it to python list of list data structure. + +## Libraries Required +1. xlrd +`$pip install xlrd` + +## Usage +A sample script `excel_to_list_usage.py` has been provided to show the usage of the ExcelToList. It reads the excel and its sheet, and prints the list of list. \ No newline at end of file diff --git a/Excel_to_ListofList/__init__.py b/Excel_to_ListofList/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Excel_to_ListofList/excel_to_list_usage.py b/Excel_to_ListofList/excel_to_list_usage.py new file mode 100644 index 0000000..5957cc1 --- /dev/null +++ b/Excel_to_ListofList/excel_to_list_usage.py @@ -0,0 +1,6 @@ +from ExcelToList import ExcelToList + +exceltolist = ExcelToList("input.xlsx","Sheet1") ## args : Input filename, Sheet name +list_of_list = exceltolist.convert() + +print "List of List : ",list_of_list \ No newline at end of file diff --git a/Excel_to_ListofList/input.xlsx b/Excel_to_ListofList/input.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..c403bdd098a0011eda0a30789763d9794915f8e5 GIT binary patch literal 5032 zcmaJ_cUV)|(+(X%uTqtw)X;mADlK#&bU{KyAS86@J@jUf-g~ith#*Ku=^$+p=}1S4 z2m*@07u;`uvOc>z_sPBYkIdZX%sXf1eUCmE2bTswNJt0}MT2z!my8(mZtVtxy9)|j z+@GS`bvuPfB6j^^c#p(q6$uMUUu$c;W)r*Gb{)a=GP>wZ*q1|9YATZWn$85*z@RhR zk~wVzXikU|d?(u2EE>C+6BsGTym;X2Mv;t0)a%)U28Kbo*7 zvw8JsX&3pINi|WC!Xkh^bFhGh{`uWUWDF!i8ak9|Y^ysxbYt}iY^RU??;Oz{5nfwkJDnt{!d%~AF_b{~37EqMGR~;6uuw%ue9A4+} zI01ArZxV6e%e-b|`(@R)mZLlSp&Ne2p`t033!rdaawSEEMTd4Wwi)NN33}`jVX$j2 z1L<8I+H5t!c5^qS5`l8;h&Cfa_or{))Y0}jpp4%YXY|@xLQJ!Y$X7qJN9(ap&vklyEji- z)<&*eAkz*2elf!W06@6^g$%`IWbV4ST)>i()Q_oRid#qix9mKprJ`9YdAn)J+2~T% z+4FaJp?cYTjX*Aj*XEbFAqZ!@!UZd<8u*0AGAZKQZjCo~--jxq31 z0n5Vo$Yey6*@*++LPiLp%Gqc$77W$BqVDQCpk=GsQ$BcoVDPWSei3J}8L0&J{_KW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