excel – Spreadsheet GUI – Python 3.4

excel – Spreadsheet GUI – Python 3.4

Unless you want to spend months writing your own code to translate the excel sheet into something python can use I suggest you take a look at: http://www.python-excel.org/

Depending on the type of file (.xls, .xlsx) you will need to use specific modules to read/write. Further information can be found in the library documentation.

Heres simple program that prints to screen a .xls file, this should get you started.

import xlrd
from tkFileDialog import askopenfile

data = tkFileDialog.askopenfilename()

book = xlrd.open_workbook(data) #open our xls file
sheet = book.sheets()[0] #book.sheets() returns a list of objects alternatively...
sheet = book.sheet_by_name(qqqq) #we can pull by name
sheet = book.sheet_by_index(0) #or by the index it has in excels sheet collection

r = sheet.row(0) #returns all the CELLS of row 0,
c = sheet.col_values(0) #returns all the VALUES of row 0,

datastore = [] #make a data store

for i in xrange(sheet.nrows):
    datastore.append(sheet.row_values(i)) #drop all the values in the rows into datastore
print (datastore)

Code example taken from here

excel – Spreadsheet GUI – Python 3.4

Leave a Reply

Your email address will not be published.