James McCool
commited on
Commit
·
ef95156
1
Parent(s):
ad5adce
Update contest data loading logic in app.py to handle database search and file uploads
Browse files- Set Contest_file to False initially for database search, ensuring proper handling of contest data retrieval.
- Adjusted the loading mechanism to utilize grab_contest_data for fetching contest data based on user selection, improving data management.
- Enhanced session state management for contest data, ensuring a seamless user experience when loading and displaying contest information.
app.py
CHANGED
@@ -61,7 +61,7 @@ with tab1:
|
|
61 |
st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
|
62 |
if parse_type == 'DB Search':
|
63 |
contest_name_var = st.selectbox("Select Contest to load", contest_names)
|
64 |
-
Contest_file =
|
65 |
elif parse_type == 'Manual':
|
66 |
Contest_file = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
67 |
if 'Contest' in st.session_state:
|
@@ -76,7 +76,9 @@ with tab1:
|
|
76 |
st.dataframe(st.session_state['Contest'].head(10))
|
77 |
elif parse_type == 'DB Search':
|
78 |
if st.button('Load Contest Data', key='load_contest_data'):
|
79 |
-
|
|
|
|
|
80 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
81 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
82 |
if st.session_state['Contest'] is not None:
|
|
|
61 |
st.info("Go ahead and upload a Contest file here. Only include player columns and an optional 'Stack' column if you are playing MLB.")
|
62 |
if parse_type == 'DB Search':
|
63 |
contest_name_var = st.selectbox("Select Contest to load", contest_names)
|
64 |
+
Contest_file = False
|
65 |
elif parse_type == 'Manual':
|
66 |
Contest_file = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
67 |
if 'Contest' in st.session_state:
|
|
|
76 |
st.dataframe(st.session_state['Contest'].head(10))
|
77 |
elif parse_type == 'DB Search':
|
78 |
if st.button('Load Contest Data', key='load_contest_data'):
|
79 |
+
Contest_data = grab_contest_data('MLB', contest_name_var, contest_id_map, contest_date_map)
|
80 |
+
Contest_file = True
|
81 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_data, sport_select)
|
82 |
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
83 |
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
84 |
if st.session_state['Contest'] is not None:
|