Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I want to start out by echoing your sentiment that the Documentation is really poor. But, here's what I've been able to figure out so far.</p> <p><strong>Published of Public</strong></p> <p>It is very important that your spreadsheet be "Published to The Web" as opposed to just being "Public on the web." The first is achieved by going to the "File -> Publish to The Web ..." menu item. The second is achieved by clicking the "Share" button in the upper left-hand corner of the spreadsheet.</p> <p>I checked, and your spreadsheet with key = '0Atncguwd4yTedEx3Nzd2aUZyNmVmZGRHY3Nmb3I2ZXc' is only "Public on the web." I made a copy of it to play around with for my example code. My copy has a key = '0Aip8Kl9b7wdidFBzRGpEZkhoUlVPaEg2X0F2YWtwYkE' which you will see in my sample code later.</p> <p>This "Public on the Web" vs. "Published on The Web" nonsense is obviously a point of common confusion. It is actually documented in a red box in the <a href="https://developers.google.com/google-apps/spreadsheets/#spreadsheets_api_urls_visibilities_and_projections" rel="noreferrer">"Visibilities and Projections"</a> sections of the main API documentation. However, it is really hard to read that document.</p> <p><strong>Visibility and Projections</strong></p> <p>As that same document says, there are projections other than "full." And in fact (undocumented), "full" doesn't seem to play nicely with a visibility of "public" which is also important to set when making unauthenticated calls.</p> <p>You can kind of glean from the <a href="http://gdata-python-client.googlecode.com/hg/pydocs/gdata.spreadsheet.service.html" rel="noreferrer">pydocs</a> that many of the methods on the SpreadsheetsService object can take "visibility" and "projection" parameters. I know only of "public" and "private" visibilities. If you learn of any others, I'd like to know about them too. It seems that "public" is what you should use when making unauthenticated calls.</p> <p>As for Projections, it is even more complicated. I know of "full", "basic", and "values" projections. I only got lucky and found the "values" projection by reading the source code to the excellent <a href="http://builtbybalance.com/Tabletop/" rel="noreferrer">Tabletop</a> javascript library. And, guess what, that's the secret missing ingredient to make things work.</p> <p><strong>Working Code</strong></p> <p>Here is some code you can use to query the worksheets from my copy of your spreadsheet.</p> <pre><code>#!/usr/bin/python from gdata.spreadsheet.service import SpreadsheetsService key = '0Aip8Kl9b7wdidFBzRGpEZkhoUlVPaEg2X0F2YWtwYkE' client = SpreadsheetsService() feed = client.GetWorksheetsFeed(key, visibility='public', projection='basic') for sheet in feed.entry: print sheet.title.text </code></pre> <p>** Tips ** I find it really helpful when working with terribly documented python APIs to use the <a href="http://docs.python.org/library/functions.html?highlight=dir#dir" rel="noreferrer">dir()</a> method in a running python interpreter to find out more about the kind of information I can get from the python objects. In this case, it doesn't help too much because the abstraction above the XML and URL based API is pretty poor.</p> <p>By the way, I'm sure you are going to want to start dealing with the actual data in the spreadsheet, so I'll go ahead and toss in one more pointer. The data for each row organized as a dictionary can be found using GetListFeed(key, sheet_key, visibility='public', projection='values').entry[0].custom</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload