James McCool
commited on
Commit
·
1bf8256
1
Parent(s):
f5d67d4
Implement conditional loading of contest data based on user selection in app.py
Browse files- Added functionality to load contest data either through manual file upload or database search, enhancing user experience and flexibility.
- Streamlined the process for handling contest files, ensuring data is cleaned and displayed effectively after loading.
app.py
CHANGED
|
@@ -66,14 +66,22 @@ with tab1:
|
|
| 66 |
Contest_file = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 67 |
if 'Contest' in st.session_state:
|
| 68 |
del st.session_state['Contest']
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
with col2:
|
| 79 |
st.subheader("Projections File")
|
|
|
|
| 66 |
Contest_file = st.file_uploader("Upload Contest File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
|
| 67 |
if 'Contest' in st.session_state:
|
| 68 |
del st.session_state['Contest']
|
| 69 |
+
if parse_type == 'Manual':
|
| 70 |
+
if Contest_file and 'Adj_Contest' not in st.session_state:
|
| 71 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
|
| 72 |
+
st.session_state['Contest'] = st.session_state['Contest'].dropna(how='all')
|
| 73 |
+
st.session_state['Contest'] = st.session_state['Contest'].reset_index(drop=True)
|
| 74 |
+
if st.session_state['Contest'] is not None:
|
| 75 |
+
st.success('Contest file loaded successfully!')
|
| 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 |
+
st.session_state['Contest'], st.session_state['ownership_df'], st.session_state['actual_df'], st.session_state['entry_list'] = load_contest_file(Contest_file, sport_select)
|
| 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:
|
| 83 |
+
st.success('Contest file loaded successfully!')
|
| 84 |
+
st.dataframe(st.session_state['Contest'].head(10))
|
| 85 |
|
| 86 |
with col2:
|
| 87 |
st.subheader("Projections File")
|