Esempio n. 1
0
 def readTable(self,tablename):
     data = xlrd.open_workbook(self.excelpath)
     table = data.sheet_by_name(tablename)
     nrows = table.nrows
     ncols = table.ncols
     header = table.row_values(0)
     tabledata = []
     i = 1
     while i < nrows:
         rdata = table.row_values(i)
         if rdata[0]:
             if isinstance(rdata[0],float):
                 rdata[0] = int(rdata[0])
             j = 0
             row = {}
             while j <len(header):                         
                 row.setdefault(header[j],rdata[j])
                 j = j+1   
             tabledata.append(row)
         i=i+1
     return tabledata
Esempio n. 2
0
 def readTable(self, tablename):
     data = xlrd.open_workbook(self.excelpath)
     table = data.sheet_by_name(tablename)
     nrows = table.nrows
     ncols = table.ncols
     header = table.row_values(0)
     tabledata = []
     i = 1
     while i < nrows:
         rdata = table.row_values(i)
         if rdata[0]:
             if isinstance(rdata[0], float):
                 rdata[0] = int(rdata[0])
             j = 0
             row = {}
             while j < len(header):
                 row.setdefault(header[j], rdata[j])
                 j = j + 1
             tabledata.append(row)
         i = i + 1
     return tabledata
Esempio n. 3
0
 def readTables(self,tablesname):
     tablesdata = {}
     for tablename in tablesname:
         table = self.data.sheet_by_name(tablename)
         nrows = table.nrows
         ncols = table.ncols
         header = table.row_values(0)
         tabledata = []
         i = 1
         while i < nrows:
             rdata = table.row_values(i)
             if rdata[0]:    
                 if isinstance(rdata[0],float):
                     rdata[0] = int(rdata[0])
                 j = 0
                 row = {}
                 while j <len(header):                
                     row.setdefault(header[j],rdata[j])
                     j = j+1           
                 tabledata.append(row)
             i=i+1
         tablesdata.setdefault(tablename,tabledata)
     return tablesdata