Skip to content

Instantly share code, notes, and snippets.

@merltron-pa
Created September 29, 2020 14:11
Show Gist options
  • Save merltron-pa/7a37917dbb23e650dbb0605713a5784d to your computer and use it in GitHub Desktop.
Save merltron-pa/7a37917dbb23e650dbb0605713a5784d to your computer and use it in GitHub Desktop.
multitouch_article_pt1
#import the json file with the google credentials
with open("google_credentials.json", "r") as f:
google_credentials = json.load(f)
#load the credentials in the right variable
scope = ['https://www.googleapis.com/auth/cloud-platform', 'https://spreadsheets.google.com/feeds']
credentials_gs = ServiceAccountCredentials.from_json_keyfile_dict(google_credentials, scope)
gc = gspread.authorize(credentials_gs)
#pull data from the right google spreadsheet and insert it into a dataframe
spreadsheet_key = 'YOUR_SPREADSHEET_KEY'
book = gc.open_by_key(spreadsheet_key)
worksheet = book.worksheet("GA raw data")
table = worksheet.get_all_values()
ga_raw_data = pd.DataFrame(table[1:], columns=table[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment