Skip to content
egradman edited this page Jul 13, 2014 · 3 revisions

This is community generated cookbook. Please, feel free to share your recipes.

gspread with pandas

Had to share... this was just too easy.

import gspread
import pandas
gc = gspread.login('my@email.com', 'supersecretekey')
book = gc.open('My Spreadsheet')
sheet = book.sheet1 #in this case
dataframe = pandas.DataFrame(sheet.get_all_records())

And to add data to a spreadsheet from a dataframe...

for row in dataframe.iterrows():
    sheet.append_row(row[1].tolist())

Nice!

A minimal IPython Notebook that handles OAuth2

You won't need to store your username or password in this IPython notebook. The first time you run it, it will take you through the authorization process automatically and cache your credentials.

https://gist.github.com/egradman/3b8140930aef97f9b0e4

See the sample.pdf for what it looks like.

Clone this wiki locally