Skip to content

Instantly share code, notes, and snippets.

@dkatz23238
Created March 16, 2019 17:20
Show Gist options
  • Save dkatz23238/185f5b15294e7bea1f31233f82b66e13 to your computer and use it in GitHub Desktop.
Save dkatz23238/185f5b15294e7bea1f31233f82b66e13 to your computer and use it in GitHub Desktop.
from io import BytesIO
import requests
from pandas import read_csv
def pandas_read_gsheets(GSHEET_ID):
''' Returns a pandas DataFrame from a spreadsheet in google sheets. Make sure the spreadsheet has a "view" link and only contains one tab of data.'''
r = requests.get('https://docs.google.com/spreadsheets/d/%s/export?format=csv' % GSHEET_ID)
data = r.content
df = read_csv(BytesIO(data))
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment