google sheet python update

Solutions on MaxInterview for google sheet python update by the best coders in the world

showing results for - "google sheet python update"
Claire
21 Mar 2020
1from oauth2client.service_account import ServiceAccountCredentials
2import gspread
3
4scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive',
5         'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/spreadsheets']
6
7#Generate a json file by using service account auth in google developer console
8'''
9Link: https://console.developers.google.com/
101) Enable API Access for a Project if you haven’t done it yet.
112) Go to “APIs & Services > Credentials” and choose “Create credentials > Service account key”.
123) Fill out the form
134) Click “Create” and “Done”.
145) Press “Manage service accounts” above Service Accounts.
156) Press on ⋮ near recently created service account and select “Manage keys” and then click on “ADD KEY > Create new key”.
167) Select JSON key type and press “Create”.
17'''
18creds = ServiceAccountCredentials.from_json_keyfile_name('mod.json', scope)
19client = gspread.authorize(creds)
20
21sheet = client.open_by_url("#Paste yout google sheet url here").sheet1
22
23data = sheet.get_all_records()
24
25sheet.update_cell(1, 1, "You made it") #Write this message in first row and first column
26
27print(data)
28