Saturday, September 29, 2012

Ipython notebook

I tested Ipython notebook today, it's nice to be able to test little pieces of python code in the browser.Using Ipython for interactive work.

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/