Spaces:
Sleeping
Sleeping
Create data_upload.py
Browse files- src/data_upload.py +17 -0
src/data_upload.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gspread
|
2 |
+
from oauth2client.service_account import ServiceAccountCredentials
|
3 |
+
|
4 |
+
def connect_to_sheet():
|
5 |
+
scope = ["https://spreadsheets.google.com/feeds",
|
6 |
+
"https://www.googleapis.com/auth/spreadsheets",
|
7 |
+
"https://www.googleapis.com/auth/drive"]
|
8 |
+
|
9 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)
|
10 |
+
client = gspread.authorize(creds)
|
11 |
+
|
12 |
+
sheet = client.open("leaderboard").sheet1
|
13 |
+
return sheet
|
14 |
+
|
15 |
+
def append_score(timestamp, score, filename):
|
16 |
+
sheet = connect_to_sheet()
|
17 |
+
sheet.append_row([timestamp, score, filename])
|