python script to read google spreadsheet

Discussion in 'Python' started by charu gangal, Nov 1, 2010.

  1. charu gangal

    charu gangal Guest

    import gdata.spreadsheet.service
    username = ''
    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.
    charu gangal, Nov 1, 2010
    #1
    1. Advertising

  2. In message
    <>, charu
    gangal wrote:

    > 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.


    What does it do instead?
    Lawrence D'Oliveiro, Nov 1, 2010
    #2
    1. Advertising

  3. charu gangal

    charu gangal Guest

    This is the page i am getting on localhost 8080. The code is showing
    me thr result only in Eclipse but not through google app engine
    launcher.

    Traceback (most recent call last):
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 3211, in _HandleRequest
    self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 3154, in _Dispatch
    base_env_dict=env_dict)
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 527, in Dispatch
    base_env_dict=base_env_dict)
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 2404, in Dispatch
    self._module_dict)
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 2314, in ExecuteCGI
    reset_modules = exec_script(handler_path, cgi_path, hook)
    File "C:\Program Files (x86)\Google\google_appengine\google\appengine
    \tools\dev_appserver.py", line 2210, in ExecuteOrImportScript
    exec module_code in script_module.__dict__
    File "C:\Users\Admin\Pythonworkspace\pythonsample12\src
    \engineapp202\main.py", line 4, in <module>
    import gdata.spreadsheet.service
    ImportError: No module named gdata.spreadsheet.service
    charu gangal, Nov 1, 2010
    #3
  4. charu gangal

    germon

    Joined:
    Dec 18, 2011
    Messages:
    1
    use gspread

    Hi Charu!

    There's simpler solution, use gspread library for your spreadsheet:


    import gspread

    client = gspread.login('your_email', 'your_password')

    worksheet = client.open('name of your spreadsheet').sheet1

    value = worksheet.acell('B1').value



    that's it.
    germon, Dec 18, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Twomey
    Replies:
    1
    Views:
    12,580
    Roger Twomey
    Apr 27, 2004
  2. Replies:
    2
    Views:
    2,011
    Jeffrey Schwab
    Nov 28, 2005
  3. Mahernoz
    Replies:
    1
    Views:
    390
    John Timney \(MVP\)
    Sep 10, 2007
  4. David
    Replies:
    1
    Views:
    1,101
    David
    Jan 13, 2009
  5. MAHERNOZ

    How to open my gridview to a google spreadsheet

    MAHERNOZ, Sep 10, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    109
    MAHERNOZ
    Sep 10, 2007
Loading...

Share This Page