gspread is a package by Anton Burnashev offers a simple interface between Python and Google Spreadsheet’s API.
Installation
Authorization
Google Spreadsheet’s API uses OAuth2 to handle authorization. You’ll need to generate an API Key. You can also use email/password to login with gspread.login(email,password)
.
Accessing Data
The gspread.Worksheet.get_all_values()
returns a list of lists which is easily converted to NumPy format or just indexing normally. You can also get a specific row with gspread.Worksheet.row_values()
and a specific cell with gspread.Worksheet.cell()
.
Updating Cells
There are other functions to update the data, mainly gspread.Worksheet.append_row()
. You can also change the size of the worksheet with gspread.Worksheet.add_rows()
,gspread.Worksheet.add_cols()
, gspread.Worksheet.resize()
.