Last active
April 3, 2022 00:58
-
-
Save jakebox/32af28f79454af356f227c7c102377d0 to your computer and use it in GitHub Desktop.
Google Sheets Retriever
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
### 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