Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created June 19, 2019 12:53
Show Gist options
  • Save DataSolveProblems/a06264fe101e832698392a4a890aa549 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/a06264fe101e832698392a4a890aa549 to your computer and use it in GitHub Desktop.
from Google import Create_Service
import pandas as pd
CLIENT_SECRET_FILE = 'client_secret.json'
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
gsheetId = '<Google Sheet Id>'
s = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION, SCOPES)
gs = s.spreadsheets()
rows = gs.values().get(spreadsheetId=gsheetId,range='Test1').execute()
data = rows.get('values')
df = pd.DataFrame(data)
print(df)
@mick-d
Copy link

mick-d commented Feb 7, 2020

I'd suggest this code totally screws up the data by interpreting header as first row of data. Instead i'd do something along these lines:
https://gist.github.com/mick-d/d2dbb35151198ef9d6db11cf422f9c1b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment