Spaces:
Runtime error
Runtime error
Update src/gsheets.py
Browse files- src/gsheets.py +3 -1
src/gsheets.py
CHANGED
|
@@ -3,12 +3,14 @@ from gspread_dataframe import set_with_dataframe
|
|
| 3 |
import pandas as pd
|
| 4 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 5 |
from datetime import datetime
|
|
|
|
| 6 |
|
| 7 |
def upload_csv_to_new_worksheet(topic_string):
|
| 8 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
| 9 |
|
| 10 |
# link service account with roles set and api enabled
|
| 11 |
-
|
|
|
|
| 12 |
client = gspread.authorize(creds)
|
| 13 |
|
| 14 |
spreadsheet = client.open_by_url('https://docs.google.com/spreadsheets/d/12N10KBYoPwFnvu3iTRgfGhVVlNFeo06BxVDlcFnwSC4/edit#gid=1761713442')
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 5 |
from datetime import datetime
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
def upload_csv_to_new_worksheet(topic_string):
|
| 9 |
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
| 10 |
|
| 11 |
# link service account with roles set and api enabled
|
| 12 |
+
gcp_service_account_key = os.environ.get("GCP_SERVICE_ACCOUNT_KEY")
|
| 13 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name(gcp_service_account_key, scope)
|
| 14 |
client = gspread.authorize(creds)
|
| 15 |
|
| 16 |
spreadsheet = client.open_by_url('https://docs.google.com/spreadsheets/d/12N10KBYoPwFnvu3iTRgfGhVVlNFeo06BxVDlcFnwSC4/edit#gid=1761713442')
|