Thursday, December 18, 2008

Spreadsheets API

(My Original Blog Post: -*http://api-madness.com/post/spreadsheets-api/)
[youtube]http://www.youtube.com/watch?v=bSzswdbqGVw[/youtube]

Attention! API Garbage (might be unreadable):

spreadsheets spreadsheet data

Were GCA API might already be familiar with Google spreadsheets online spreadsheets application that allows for real-time collaboration is part of a Google box we ve spreadsheets API allows you to programmatically access and modify your spreadsheet data in your language of choice provides client libraries in a variety of languages which simplify working with the spreadsheets API I ve recently made an addition to the Python library that makes it easier to use spreadsheets as a simple text database of the great things about using Google spreadsheets is a simple database is that you can see and modify all of your data from a nice user interface and is available on a machine as long as you re connected to the Internet you can interact with the data in your Google documents but start first off the Python client libraries open source and available at code.google.com. data Python client this module is called text DB and it lives within the G-8 a spreadsheet package of Judah client library spreadsheet module allows you to use all the features in the spreadsheets API and the new text DB module is built on top of it the 60 B. module streamlines a specific use case and makes using the spreadsheets API feel like using a simple database is much more that you can do with the spreadsheets API like use formulas and data from other sources and update a large number of cells at once but I decided to make this module about ease-of-use lets take a look at a sample of how to use the text DB module will begin by importing the module which has classes that make it easy use Google spreadsheets like a simple database in the next importer demo module which enters my e-mail address for me so that s not broadcast of the world thanks to this video that we can create a new Google spreadsheet using our client is easy when you need to provide is a name the database object represents our new Google spreadsheet and were ready to create a table but first let s take a look at this document in toolbox okay let s say that we have a table of nights and want to ask their name quest and favorite color or spreadsheet now has a new worksheet and we re ready to add some information on the open net now and will see a new row appear in our spreadsheet which also at information through the spreadsheets user interface for working with existing data we may need to start by finding the spreadsheet which you can do by looking up the name of the spreadsheet or the unique spreadsheet Key ID since you can have multiple spreadsheets with the same name to get databases method returns a list you can retrieve rows of data in several ways you can look up a single row or request a range of rows using get records since we only have three rows of data rows contains three items you can also search for roast which match certain requirements using spreadsheet structured query language structured queries can contain and were less than greater than exact matches and not equals we had two nights with the favorite color of blue so as you can see we have two matches once we have a rows we can make changes to the data in our Google spreadsheet and other potential challengers and storing your data in the cloud is that read and write operations may be slow because they re transferring data or were slow and potentially flaky network connections to avoid this problem in the text DB library changes to local objects are only sent to the server when the push method in our example earlier we forgot xb7 hats cost let s do that now let s take a look at the content and the record now we re going to send this change to the server and we should see the class in our spreadsheet update I also see that we got Galahad s favor Colorado to show retrieving updates which have happened outside of a local copy of the data will make a change in the spreadsheet or local copy doesn t have the change yet but after reportedly you can see that the content has been updated I just walked you through a simple example of using the text DB module to use Google spreadsheets as if it were database and caught this is just one of the ways that you can use the spreadsheets API and although this example is in Python a similar library could be built in almost any language all the code that I ve used in the sample is open source so you re free to copy it and modify it as you like if you think of some other interesting things that you d like to do using the spreadsheets API would love to hear about it please visit us in the Google docs to API group you can also check out the documentation for the API on code.google.com

No comments: