James McCool
commited on
Commit
·
98de8e5
1
Parent(s):
32e941f
Enhance contest file loading in app.py and load_contest_file.py to support additional data structures
Browse files- Updated load_contest_file function to return salary_df, team_df, and pos_df based on the helper variable, improving data handling for contest files.
- Modified app.py to accommodate the new return values, ensuring proper session state management for salary, team, and position data.
- Maintained existing functionality while expanding the data output capabilities during contest file processing.
- app.py +10 -5
- global_func/load_contest_file.py +5 -2
app.py
CHANGED
|
@@ -125,9 +125,9 @@ with tab1:
|
|
| 125 |
|
| 126 |
if 'Contest_file' in st.session_state:
|
| 127 |
if 'Contest_file_helper' in st.session_state:
|
| 128 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], st.session_state['Contest_file_helper'], sport_select)
|
| 129 |
else:
|
| 130 |
-
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], st.session_state['player_info'], sport_select)
|
| 131 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 132 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 133 |
if st.session_state['Contest'] is not None:
|
|
@@ -137,9 +137,14 @@ with tab1:
|
|
| 137 |
if 'Contest_file' in st.session_state:
|
| 138 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
| 139 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_df']['Player'], st.session_state['actual_df']['FPTS']))
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
st.write(st.session_state['salary_dict'])
|
| 145 |
|
|
|
|
| 125 |
|
| 126 |
if 'Contest_file' in st.session_state:
|
| 127 |
if 'Contest_file_helper' in st.session_state:
|
| 128 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['salary_df'], st.session_state['team_df'], st.session_state['pos_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], 1, st.session_state['Contest_file_helper'], sport_select)
|
| 129 |
else:
|
| 130 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'], check_lineups = load_contest_file(st.session_state['Contest_file'], 0, st.session_state['player_info'], sport_select)
|
| 131 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 132 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 133 |
if st.session_state['Contest'] is not None:
|
|
|
|
| 137 |
if 'Contest_file' in st.session_state:
|
| 138 |
st.session_state['ownership_dict'] = dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own']))
|
| 139 |
st.session_state['actual_dict'] = dict(zip(st.session_state['actual_df']['Player'], st.session_state['actual_df']['FPTS']))
|
| 140 |
+
if 'Contest_file_helper' not in st.session_state:
|
| 141 |
+
st.session_state['salary_dict'] = st.session_state['info_maps']['salary_dict']
|
| 142 |
+
st.session_state['team_dict'] = st.session_state['info_maps']['team_dict']
|
| 143 |
+
st.session_state['pos_dict'] = st.session_state['info_maps']['position_dict']
|
| 144 |
+
else:
|
| 145 |
+
st.session_state['salary_dict'] = dict(zip(st.session_state['salary_df']['Player'], st.session_state['salary_df']['Salary']))
|
| 146 |
+
st.session_state['team_dict'] = dict(zip(st.session_state['team_df']['Player'], st.session_state['team_df']['Team']))
|
| 147 |
+
st.session_state['pos_dict'] = dict(zip(st.session_state['pos_df']['Player'], st.session_state['pos_df']['Pos']))
|
| 148 |
|
| 149 |
st.write(st.session_state['salary_dict'])
|
| 150 |
|
global_func/load_contest_file.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
from rapidfuzz import process, fuzz
|
| 4 |
|
| 5 |
-
def load_contest_file(upload, helper = None, sport = None):
|
| 6 |
if upload is not None:
|
| 7 |
try:
|
| 8 |
try:
|
|
@@ -136,7 +136,10 @@ def load_contest_file(upload, helper = None, sport = None):
|
|
| 136 |
entry_list = list(set(df['BaseName']))
|
| 137 |
entry_list.sort()
|
| 138 |
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
except Exception as e:
|
| 142 |
st.error(f'Error loading file: {str(e)}')
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from rapidfuzz import process, fuzz
|
| 4 |
|
| 5 |
+
def load_contest_file(upload, helper_var, helper = None, sport = None):
|
| 6 |
if upload is not None:
|
| 7 |
try:
|
| 8 |
try:
|
|
|
|
| 136 |
entry_list = list(set(df['BaseName']))
|
| 137 |
entry_list.sort()
|
| 138 |
|
| 139 |
+
if helper_var == 1:
|
| 140 |
+
return cleaned_df, ownership_df, fpts_df, salary_df, team_df, pos_df, entry_list, check_lineups
|
| 141 |
+
else:
|
| 142 |
+
return cleaned_df, ownership_df, fpts_df, entry_list, check_lineups
|
| 143 |
|
| 144 |
except Exception as e:
|
| 145 |
st.error(f'Error loading file: {str(e)}')
|