Reading a MS Excel table and creating double list
Code: "io_ms_excel4.py". Programming language: Python DMelt Version 1.2. Last modified: 07/09/2015. License: Pro
https://datamelt.org/code/cache/io_ms_excel4_4225.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


# run io_ms_excel2.py  example first!
 
from  org.apache.poi.xssf.usermodel import XSSFWorkbook 
from  org.apache.poi.ss.usermodel import Cell
from  java.io import *

f=FileInputStream(File("table2.xlsx"));
wb = XSSFWorkbook(f)
sheet=wb.getSheetAt(0) # first sheet from the workbook

elist=[]
row= sheet.iterator()
while (row.hasNext()):
   r = row.next();
   c = r.cellIterator();
   lrow=[] 
   while(c.hasNext()):
        cell=c.next()
        if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC):
             lrow.append(cell.getNumericCellValue())
   if (len(lrow)>0):elist.append(lrow)
print elist

Ads help maintain this website.