Follow steps in the link. Then use this code
import pandas as pd
import gspread
from oauth2client.service_account import ServiceAccountCredentials
utils_dir = '11_utils/'
# use creds to create a client to interact with the Google Drive API
#scope = ['https://spreadsheets.google.com/feeds']
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name(utils_dir+'sheets_api.json', scope)
client = gspread.authorize(creds)
# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet = client.open("live_prices").sheet1
data = sheet.get_all_records() # Get a list of all records
df = pd.DataFrame(data)
No comments:
Post a Comment