Skip to content

Instantly share code, notes, and snippets.

@garymanley
Created January 7, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garymanley/c23728f14950a65bdef8c46597ebcbba to your computer and use it in GitHub Desktop.
Save garymanley/c23728f14950a65bdef8c46597ebcbba to your computer and use it in GitHub Desktop.
Google Sheets
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 7 06:21:03 2018
@author: garym
"""
### imports
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd
# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name(r'C:\Users\garym\Documents\python\client_secret.json', scope)
client = gspread.authorize(creds)
# Open the workbook
sht = client.open('HandicapRelayNY2017')
# Get sheet 4 (0,1,2,3)
sheet = sht.get_worksheet(3)
# Get all the record and put into a pandas dataframe
list_of_values = sheet.get_all_records()
df = pd.DataFrame(list_of_values)
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment