Update src/streamlit_app.py
Browse files- src/streamlit_app.py +12 -12
src/streamlit_app.py
CHANGED
|
@@ -4,7 +4,6 @@ import pandas as pd
|
|
| 4 |
import gspread
|
| 5 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 6 |
import traceback
|
| 7 |
-
import json
|
| 8 |
import io
|
| 9 |
|
| 10 |
# Google Sheets configuration
|
|
@@ -69,7 +68,7 @@ HEADERS = {
|
|
| 69 |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
|
| 70 |
}
|
| 71 |
|
| 72 |
-
# Excel data
|
| 73 |
EXCEL_DATA = """id name short_name jersey_no position_id position is_substitute is_substituted isPlaying minutes_played jersey starter captain is_Injured offloads line_breaks defenders_beaten points try_assists tries tackles turnovers_won yellow_cards red_cards handling_errors knock_ons conversions penalty_goals points_scored tries_scored conversions penalty_goals
|
| 74 |
165 Pol Pla Pol Pla 7 4 Back 0 0 0 18 7 1 1 0 0 0 0 0 1 0 3 0 0 0 0 0 0 0 0 0 0 0
|
| 75 |
191 Tone Ng Shiu Tone Ng Shiu 3 3 Hybrid 0 0 0 12 3 1 0 0 1 0 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
@@ -103,13 +102,15 @@ def load_excel_data():
|
|
| 103 |
try:
|
| 104 |
# Read Excel data from string
|
| 105 |
df = pd.read_csv(io.StringIO(EXCEL_DATA), sep='\t')
|
| 106 |
-
# Select
|
| 107 |
-
columns = [
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
df = df[columns]
|
| 114 |
st.session_state["excel_data"] = df
|
| 115 |
return df
|
|
@@ -149,9 +150,8 @@ def write_to_google_sheet(data):
|
|
| 149 |
st.write("Debug: Clearing existing data")
|
| 150 |
sheet.clear()
|
| 151 |
|
| 152 |
-
# Write data
|
| 153 |
st.write("Debug: Writing Excel data")
|
| 154 |
-
# Convert DataFrame to list of lists (including headers)
|
| 155 |
data_values = [data.columns.tolist()] + data.values.tolist()
|
| 156 |
sheet.update('A1', data_values)
|
| 157 |
|
|
@@ -164,7 +164,7 @@ def write_to_google_sheet(data):
|
|
| 164 |
|
| 165 |
def main():
|
| 166 |
st.title("Rugby Premier League Data Fetcher")
|
| 167 |
-
st.write("Processing data for match ID 43 (Bengaluru Bravehearts vs. Delhi Redz) at 05:
|
| 168 |
|
| 169 |
# Load Excel data
|
| 170 |
st.subheader("Excel Data (Squad)")
|
|
|
|
| 4 |
import gspread
|
| 5 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 6 |
import traceback
|
|
|
|
| 7 |
import io
|
| 8 |
|
| 9 |
# Google Sheets configuration
|
|
|
|
| 68 |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
|
| 69 |
}
|
| 70 |
|
| 71 |
+
# Excel data (same as provided earlier)
|
| 72 |
EXCEL_DATA = """id name short_name jersey_no position_id position is_substitute is_substituted isPlaying minutes_played jersey starter captain is_Injured offloads line_breaks defenders_beaten points try_assists tries tackles turnovers_won yellow_cards red_cards handling_errors knock_ons conversions penalty_goals points_scored tries_scored conversions penalty_goals
|
| 73 |
165 Pol Pla Pol Pla 7 4 Back 0 0 0 18 7 1 1 0 0 0 0 0 1 0 3 0 0 0 0 0 0 0 0 0 0 0
|
| 74 |
191 Tone Ng Shiu Tone Ng Shiu 3 3 Hybrid 0 0 0 12 3 1 0 0 1 0 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
|
|
| 102 |
try:
|
| 103 |
# Read Excel data from string
|
| 104 |
df = pd.read_csv(io.StringIO(EXCEL_DATA), sep='\t')
|
| 105 |
+
# Select requested columns (excluding duplicate 'conversions')
|
| 106 |
+
columns = [
|
| 107 |
+
'id', 'name', 'short_name', 'jersey_no', 'position_id', 'position',
|
| 108 |
+
'is_substitute', 'is_substituted', 'isPlaying', 'minutes_played',
|
| 109 |
+
'jersey', 'starter', 'captain', 'offloads', 'line_breaks',
|
| 110 |
+
'defenders_beaten', 'points', 'try_assists', 'tries', 'tackles',
|
| 111 |
+
'turnovers_won', 'yellow_cards', 'red_cards', 'handling_errors',
|
| 112 |
+
'conversions', 'penalty_goals', 'points_scored', 'tries_scored'
|
| 113 |
+
]
|
| 114 |
df = df[columns]
|
| 115 |
st.session_state["excel_data"] = df
|
| 116 |
return df
|
|
|
|
| 150 |
st.write("Debug: Clearing existing data")
|
| 151 |
sheet.clear()
|
| 152 |
|
| 153 |
+
# Write data
|
| 154 |
st.write("Debug: Writing Excel data")
|
|
|
|
| 155 |
data_values = [data.columns.tolist()] + data.values.tolist()
|
| 156 |
sheet.update('A1', data_values)
|
| 157 |
|
|
|
|
| 164 |
|
| 165 |
def main():
|
| 166 |
st.title("Rugby Premier League Data Fetcher")
|
| 167 |
+
st.write("Processing data for match ID 43 (Bengaluru Bravehearts vs. Delhi Redz) at 05:24 PM IST, June 23, 2025")
|
| 168 |
|
| 169 |
# Load Excel data
|
| 170 |
st.subheader("Excel Data (Squad)")
|