Skip to content

Instantly share code, notes, and snippets.

@jakebox
Last active April 3, 2022 00:58
Show Gist options
  • Save jakebox/32af28f79454af356f227c7c102377d0 to your computer and use it in GitHub Desktop.
Save jakebox/32af28f79454af356f227c7c102377d0 to your computer and use it in GitHub Desktop.
Google Sheets Retriever
###
### Google Sheets Data Retriever
### By Jake B - December 2019
### Uses gspread and Google Drive API to retrieve
### data from Google sheets spreadsheet
###
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# 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('client_secret.json', scope) # Get these from the Google Developer Console
client = gspread.authorize(creds)
# Opening sheet via url - make sure link sharing is enabled
sheet = client.open_by_url('LINK GOES HERE').sheet1
# Extract the the values into a list, with sublists of rows
list_of_values = sheet.get_all_values()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment