How can i use Spread Sheet as Data Store

Jeff McNeil jeff at jmcneil.net
Tue May 19 00:30:26 EDT 2009


On May 18, 11:45 pm, Wincent <ronggui.hu... at gmail.com> wrote:
> 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?

I didn't see it mentioned yet, but the Google Spreadsheet application
is also something you could use if you have a choice. It has a fairly
useful API that let's you manage elements. I'm not sure if it's an
option for you or not.

http://code.google.com/apis/spreadsheets/overview.html

Thanks,

Jeff
mcjeff.blogspot.com



More information about the Python-list mailing list