-
Notifications
You must be signed in to change notification settings - Fork 0
/
spreadsheet.py
28 lines (20 loc) · 937 Bytes
/
spreadsheet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gspread
from oauth2client.service_account import ServiceAccountCredentials
gsheet_id = '1twnRPyhNn8Dfg_ybybRluEIYSh0sa9dHniM9t07qjzM'
def gsheet_store(activeCases, recoveries, deaths):
print('Accessing gooogle sheet...')
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name(
'client_secret.json', scope)
client = gspread.authorize(creds)
ws = client.open_by_key(gsheet_id).sheet1
col = ws.col_values(13)
toInsert = len(col) + 1
print('Row to insert val at ',toInsert)
ws.update_cell(toInsert, 17, activeCases)
print('Active cases stored at row ', toInsert)
ws.update_cell(toInsert, 15, recoveries)
print('Recoveries stored at row ', toInsert)
ws.update_cell(toInsert, 13, deaths)
print('Deaths stored at at row ', toInsert)