Spaces:
Sleeping
Sleeping
Create google_sheet.py
Browse files123456789101112131415161718192021222324# ========================# Google Sheets Integration# ========================
def connect_to_sheet(): creds_dict = json.loads(os.environ["GOOGLE_CREDS_JSON"]) scope = [ "https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive" ] creds = ServiceAccountCredentials.from_json_keyfile_dict(creds_dict, scope) client = gspread.authorize(creds) sheet = client.open("Hackathon Leaderboard").sheet1 return sheet
def append_score(timestamp, score, filename): sheet = connect_to_sheet() sheet.append_row([timestamp, score, filename])
def fetch_leaderboard(): sheet = connect_to_sheet() data = sheet.get_all_records() return pd.DataFrame(data)src/google_sheet.pyAdded+24