python script to read google spreadsheet

C

charu gangal

import gdata.spreadsheet.service
username = '(e-mail address removed)'
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.
 
L

Lawrence D'Oliveiro

In message
charu said:
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?
 
C

charu gangal

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
 
Joined
Dec 18, 2011
Messages
1
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top