Skip to content

Instantly share code, notes, and snippets.

@harshmaur
Created November 5, 2022 07:58
Show Gist options
  • Save harshmaur/ea0d932a2b11f3f3219cc1dcb17fe0b1 to your computer and use it in GitHub Desktop.
Save harshmaur/ea0d932a2b11f3f3219cc1dcb17fe0b1 to your computer and use it in GitHub Desktop.
Download Sheet and Get Records
credential_path = "credentials.json" # ensure the path is correct.
sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # replace with the sheet url
worksheet_name = "Sheet1" # Name of the worksheet you want to access
gc = gspread.service_account(pkg_resources.resource_filename(__name__, credential_path))
sh = gc.open_by_url(sheet_url)
worksheet = sh.worksheet(worksheet_name)
records = worksheet.get_all_records()
df = pd.DataFrame(records)
# Now you can use df to do your operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment