How can i use Spread Sheet as Data Store

Wincent ronggui.huang at gmail.com
Mon May 18 23:45:31 EDT 2009


If you want to write to a csv file, the other option is savetxt in
NumPy module.

Best

On May 19, 7:29 am, John Machin <sjmac... at lexicon.net> wrote:
> On May 19, 5:12 am, Terry Reedy <tjre... at udel.edu> wrote:
>
> > Kalyan Chakravarthy wrote:
> > > Hi All,
> > >              I have data in Spread Sheet ( First Name and Last Name),
> > > how can i see  this data  in Python code ( how can i use Spread Sheet as
> > > Data Store ) .
>
> > I you have a choice, a plain text file is MUCH easier.
>
> for line in open('guff.txt'):
>     first, last = line.rstrip('\n').split('\t')
>
> > Or, you can output a plain text data.csv (comma-separated variable) file
> > from the spreadsheet and read that with the csv module.
>
> import csv
> for row in csv.reader(open('guff.csv', 'rb')):
>     first, last = row
>
> Or, if you have an Excel XLS file, use xlrd:
>
> import xlrd
> book = xlrd.open_workbook('guff.xls')
> sheet = book.sheet_by_index(0)
> for rowx in xrange(sheet.nrows):
>     first, last = sheet.row_values(rowx)
>
> So far I don't see "MUCH" easier ... than what? Perhaps much easier
> than using odfpy, which states right up front """Odfpy aims to be a
> complete API for OpenDocument in Python. Unlike other more convenient
> APIs, this one is essentially an abstraction layer just above the XML
> format.""" Perhaps much easier than using COM?




More information about the Python-list mailing list