Forked from DataSolveProblems/import gsheet to dataframe.py
Last active
February 7, 2020 16:34
-
-
Save mick-d/d2dbb35151198ef9d6db11cf422f9c1b to your computer and use it in GitHub Desktop.
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
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() | |
gs_data = rows.get('values') | |
gs_header = gs_data.pop(0) | |
df = pd.DataFrame(gs_data, columns=gs_header) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment