Comments (6)
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.
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.
I found the problem. in the models.py source file, the get_worksheet method doesnt raise a WorksheetNotFound. it should.
from gspread.
Well, It might be wrong, but this is by design initially. You have two basic method to access your worksheet in your spreadsheet:
Spreadsheet.worksheet(title)
– gets you a worksheet specified by its title, raisingWorksheetNotFound
in case it fails to find any worksheet.Spreadsheet.get_worksheet(index)
– gets you a worksheet by its index (starting from zero). It returnsNone
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.
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.
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)
- Add new `Worksheet` init arguments to migration guide
- Update examples of gspread usage /Readme.md HOT 8
- Reorder gspread client init arguments HOT 1
- improve documentation HOT 2
- cell.expand('table') feature requests HOT 7
- add `value_render_option` to examples (automatic conversion of currency) HOT 6
- Update conda forge package HOT 2
- A way to add DataValidation HOT 6
- Missing py.typed marker HOT 1
- AttributeError: 'HTTPClient' object has no attribute 'import_csv' HOT 3
- Unable to read public readonly spreadsheet HOT 4
- Add missing types HOT 2
- Disambiguating and filling in headers similar to Pandas HOT 8
- worksheet.add_protected_range() - impossible to create the `warning_only=True` range HOT 2
- ADC Authentication HOT 2
- HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1000)'))) HOT 2
- Questions about Copilot + Open Source Software Hierarchy HOT 1
- gspread depends on google-auth>2.4.0 but only specifies google-auth>=1.12.0 HOT 7
- Client.copy(..., copy_permissions=True) breaks when permission type is domain HOT 1
- Remove StrEnum dependency HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gspread.