A simple Python wrapper for the Google Spreadsheets API
Project description
A simple Python wrapper for the Google Spreadsheeta API. [![Build Status](https://secure.travis-ci.org/yoavaviram/python-google-spreadsheet.png?branch=master)](http://travis-ci.org/yoavaviram/python-google-spreadsheet)
Features
An object oriented interface for Worksheets
Supports List Feed view of spreadsheet rows, represented as dictionaries
Compatible with Google App Engine
Requirements
Before you get started, make sure you have:
Installed [Gdata](http://code.google.com/p/gdata-python-client/) (pip install gdata)
Usage
List Spreadsheets and Worksheets:
>>> from google_spreadsheet.api import SpreadsheetAPI >>> api = SpreadsheetAPI(GOOGLE_SPREADSHEET_USER, GOOGLE_SPREADSHEET_PASSWORD, GOOGLE_SPREADSHEET_SOURCE) >>> spreadsheets = api.list_spreadsheets() >>> spreadsheets [('MyFirstSpreadsheet', 'tkZQWzwHEjKTWFFCAgw'), ('MySecondSpreadsheet', 't5I-ZPGdXjTrjMefHcg'), ('MyThirdSpreadsheet', 't0heCWhzCmm9Y-GTTM_Q')] >>> worksheets = api.list_worksheets(spreadsheets[0][1]) >>> worksheets [('MyFirstWorksheet', 'od7'), ('MySecondWorksheet', 'od6'), ('MyThirdWorksheet', 'od4')]
Please note that in order to work with a Google Spreadsheet it must be accessible to the user who’s login credentials are provided. The GOOGLE_SPREADSHEET_SOURCE argument is used by Google to identify your application and track API calls.
Working with a Worksheet:
>>> sheet = spreadsheet.get_worksheet('tkZQWzwHEjKTWFFCAgw', 'od7') >>> rows = sheet.get_rows() >>> len(rows) 18 >>> row_to_update = rows[0] >>> row_to_update['name'] = 'New Name' >>> sheet.update_row(0, row_to_update) {'name': 'New Name'...} >>> row_to_insert = rows[0] >>> row_to_insert['name'] = 'Another Name' >>> sheet.insert_row(row_to_insert) {'name': 'Another Name'...} >>> sheet.delete_row(18) >>> sheet.delete_all_rows()
That’s it.
For more information about these calls, please consult the [Google Spreadsheets API Developer Guide](https://developers.google.com/google-apps/spreadsheets/).
Tests
To run the test suite please follow these steps:
Make sure [Nose](http://readthedocs.org/docs/nose/en/latest/) is installed: (pip install nose)
Create a local file named: test_settings.py with the following variables set to the relevant values: GOOGLE_SPREADSHEET_USER, GOOGLE_SPREADSHEET_PASSWORD, GOOGLE_SPREADSHEET_SOURCE, GOOGLE_SPREADSHEET_KEY, GOOGLE_WORKSHEET_KEY
Run nosetests
License
Copyright © 2012 Yoav Aviram
See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-google-spreadsheet-1.0.2.tar.gz
.
File metadata
- Download URL: python-google-spreadsheet-1.0.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e27552e10c3061cbbd2feb23e06027aba5643f96ceca2d4a5d7bce660aa4dccc |
|
MD5 | 04368eff1b93dfe36eb904641f4fa19a |
|
BLAKE2b-256 | 1412f0949f11452878021b2c46769506759a753e550bf8fd9b9f302de8674fbf |
File details
Details for the file python_google_spreadsheet-1.0.2-py2.7.egg
.
File metadata
- Download URL: python_google_spreadsheet-1.0.2-py2.7.egg
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a426e9e56d57f9d9406f8cb141da0d6de838a6861be422eaff0cc697514c08c8 |
|
MD5 | 65e0b0e232bd0d427231d2fbe386dfc9 |
|
BLAKE2b-256 | 11c54ad2e0fdf3a08fde656b67aafcd64b074f8e2301c92103f1f0c2870d6f5f |