Skip to content

Instantly share code, notes, and snippets.

@anbento0490
Last active March 5, 2021 07:56
Show Gist options
  • Save anbento0490/2883cfde2aef344f2496c31141e66297 to your computer and use it in GitHub Desktop.
Save anbento0490/2883cfde2aef344f2496c31141e66297 to your computer and use it in GitHub Desktop.
def gsheet2df(spreadsheet_name, sheet_num):
scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
credentials_path = 'tutorial-sa-b04b423afd77.json'
credentials = sac.from_json_keyfile_name(credentials_path, scope)
client = gspread.authorize(credentials)
sheet = client.open(spreadsheet_name).get_worksheet(sheet_num).get_all_records()
df = pd.DataFrame.from_dict(sheet)
return df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment