python script to read google spreadsheet

charu gangal charugangal at gmail.com
Mon Nov 1 02:16:11 EDT 2010


import gdata.spreadsheet.service
username        = 'prakhil.purchase at gmail.com'
passwd          = 'purchase'
doc_name        = 'googleapps_spreadsheet'
gd_client = gdata.spreadsheet.service.SpreadsheetsService()
gd_client.email = username
gd_client.password =passwd
#gd_client.source = 'pythonsample12'
gd_client.ProgrammaticLogin()
q = gdata.spreadsheet.service.DocumentQuery()
q['title'] = doc_name
q['title-exact'] = 'true'
feed = gd_client.GetSpreadsheetsFeed(query=q)
spreadsheet_id = feed.entry[0].id.text.rsplit('/',1)[1]
feed = gd_client.GetWorksheetsFeed(spreadsheet_id)
worksheet_id = feed.entry[0].id.text.rsplit('/',1)[1]
rows = gd_client.GetListFeed(spreadsheet_id, worksheet_id).entry
for row in rows:
    for key in row.custom:
        print " %s: %s" % (key, row.custom[key].text)


This is the python code I was trying to access the cell information
from a google spreadsheet but the issue is that i am able to make it
work on Eclipse but when i deploy it, it is not showing me the result.
Maybe I am missing some of the google packages to import that is
making it unable to run on google environment. Kindly guide me.Thanks
in advance.



More information about the Python-list mailing list