Saturday, September 29, 2012

Read Excel from Python

from xlrd import open_workbook
wb = open_workbook('my_file.xls')
for s in wb.sheets():
    print 'Sheet:',s.name, "has",
    print s.nrows, "rows and", s.ncols, "columns"
    print "cell(1,1) contains: ", s.cell(1,1).value   

    for row in range(s.nrows):
        values = []
        for col in range(s.ncols):
            values.append(s.cell(row,col).value)
        print ',' ,values
    print


From the python Excel tutorial here: http://www.python-excel.org/

No comments: