Skip to content

Latest commit

 

History

History
88 lines (56 loc) · 1.97 KB

index.rst

File metadata and controls

88 lines (56 loc) · 1.97 KB

gspread — Google Spreadsheets Python library

gspread is a simple library for interacting with Google Spreadsheets.

.. toctree::
   :maxdepth: 3

   userguide
   reference

Features

  • Open a spreadsheet by its title, url or key.
  • Select cells by labels, e.g. 'A1'.
  • Extract range, entire row or column values.
  • Independent of Google Data Python client library.
  • Python 3 support.

Example

This code will connect to Google Data API and fetch a cell's value from a spreadsheet:

import gspread

# Login with your Google account
gc = gspread.login('account@gmail.com','password')

# Spreadsheets can be opened by their title in Google Docs
spreadsheet = gc.open("where's all the money gone 2011")

# Get a first worksheet
worksheet = spreadsheet.sheet1

# Get a cell value
val = worksheet.acell('B1').value

# Or
val = worksheet.cell(1, 2).value

The cell's value can be easily updated:

worksheet.update_acell('B1', 'Bingo!')

# Or
worksheet.update_cell(1, 2, 'Bingo!')

To fetch a cell range, specify it by common notation:

cell_list = worksheet.range('A1:A7')

After some processing, this range can be updated in batch:

for cell in cell_list:
    cell.value = 'O_o'

worksheet.update_cells(cell_list)

Code

Check gspread on GitHub.

Any feedback is more than welcome: open up a new github issue and I'll be dancing like crazy.

Indices and tables