Giter VIP home page Giter VIP logo

Comments (6)

ashim888 avatar ashim888 commented on May 19, 2024

there are other ways to open your spreadsheet
try:
spreadsheet = gc.open_by_key('0AkgM6iO_6dprdHF0V1pQVjFlQ2FIUDd0VTZ3ZjJubWc')
OR by passing the whole URL:
spreadsheet = gc.open_by_url("https://docs.google.com/spreadsheet/ccc?key=1AkgN6IO_5rdrprh0V1pQVjFlQ2mIUDd3VTZ3ZjJubWc#gid=0")

And talking about the worksheet, its at the bottom left by default its Sheet1 i guess, better read the userguide.rst file in the zipped file or your clone inside docs folder, Cheers!

from gspread.

gholadr avatar gholadr commented on May 19, 2024

I guess what i'm saying here is, irrespective of how you chose to open your spreadsheet (by url, key, or title), if the worksheet you're trying to access doesnt exist, the WorksheetNotFound error doesnt fire, at least not that I could see.
so, for instance, if I do this:
spreadsheet = gc.open_by_key('0AkgM6iO_6dprdHF0V1pQVjFlQ2FIUDd0VTZ3ZjJubWc')
try:
worksheet = spreadsheet.sh.get_worksheet(99999)
except gspread.exceptions.WorksheetNotFound as err: <-- this should trigger but doesnt
print str(err)

from gspread.

gholadr avatar gholadr commented on May 19, 2024

I found the problem. in the models.py source file, the get_worksheet method doesnt raise a WorksheetNotFound. it should.

from gspread.

burnash avatar burnash commented on May 19, 2024

Well, It might be wrong, but this is by design initially. You have two basic method to access your worksheet in your spreadsheet:

  1. Spreadsheet.worksheet(title) – gets you a worksheet specified by its title, raising WorksheetNotFound in case it fails to find any worksheet.
  2. Spreadsheet.get_worksheet(index) – gets you a worksheet by its index (starting from zero). It returns None in case of wrong or non-existent index.

The third options is a shortcut for getting the first worksheet: Spreadsheet.sheet1 is a property of spreadsheet object that returns get_worksheet(0).

Again, this may be wrong, but it's by design. As for the following:

when opening a spreadsheet by title with the gc.open('incorrect title') method, and assuming I'm passing an
incorrect title, the Spreadsheet error doesnt output anything (unlike AuthenticationError).

This one should raise a SpreadsheetNotFound exception. See the code. And it's certainly a weird bug if it's not.

from gspread.

gholadr avatar gholadr commented on May 19, 2024

yes, you're totally correct, it looks like its by design. maybe we can turn this into a minor improvement request
as for the SpreadsheetNotFound, the error definitely fires but there isnt any error message associated with it, unlike AuthenticationError.

from gspread.

 avatar commented on May 19, 2024

Hello guys,

I have used the gspread for writing the data on google spreadsheet. Its working fine locally but when I was trying at live server it gives me a following error .

File "/home/openerp10/openerp_7.0/addons/spreadsheet_calculate_all/spreadsheet_calculate_all.py", line 53, in insert
a = c.open(title).sheet1
File "/usr/local/lib/python2.7/dist-packages/gspread-0.1.0-py2.7.egg/gspread/client.py", line 130, in open
raise SpreadsheetNotFound
SpreadsheetNotFound

The code is as follow,
if title and username and passwd:
try:
c = gspread.Client(auth=(username,passwd))
c.login()
a = c.open(title).sheet1
except Exception, e:
raise osv.except_osv(_('User Error!'), _('Please give correct google username,password and document title.'))

Please help.
Thank you!

from gspread.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.