James McCool
commited on
Commit
·
bc09bf7
1
Parent(s):
638ac79
Refactor CSV file loading logic in Data Load tab
Browse filesUpdated the handling of the CSV file upload and loading from Paydirt DB to improve session state management. Ensured that the 'pricing_loaded' state is set correctly based on the source of the CSV file, enhancing data processing reliability and user experience.
app.py
CHANGED
|
@@ -595,14 +595,20 @@ if selected_tab == 'Data Load':
|
|
| 595 |
st.info("Upload the player pricing CSV from the site you are playing on")
|
| 596 |
|
| 597 |
pricing_source = st.selectbox("Select a pricing source", options=['Paydirt DB', 'User Upload'])
|
| 598 |
-
|
|
|
|
| 599 |
|
| 600 |
upload_csv_col, csv_template_col = st.columns([3, 1])
|
| 601 |
if pricing_source == 'Paydirt DB':
|
| 602 |
if st.button("Load from Paydirt DB"):
|
| 603 |
st.session_state['csv_file'] = load_csv(nfl_reg_salaries)
|
|
|
|
| 604 |
if 'csv_file' in st.session_state:
|
| 605 |
del st.session_state['csv_file']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
else:
|
| 607 |
with upload_csv_col:
|
| 608 |
csv_file = st.file_uploader("Upload CSV File", type=['csv'])
|
|
@@ -621,11 +627,11 @@ if selected_tab == 'Data Load':
|
|
| 621 |
mime="text/csv"
|
| 622 |
)
|
| 623 |
st.session_state['csv_file'] = load_csv(csv_file)
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
|
| 630 |
if st.session_state['pricing_loaded']:
|
| 631 |
if type_var == 'Showdown':
|
|
|
|
| 595 |
st.info("Upload the player pricing CSV from the site you are playing on")
|
| 596 |
|
| 597 |
pricing_source = st.selectbox("Select a pricing source", options=['Paydirt DB', 'User Upload'])
|
| 598 |
+
if 'csv_file' not in st.session_state:
|
| 599 |
+
st.session_state['pricing_loaded'] = False
|
| 600 |
|
| 601 |
upload_csv_col, csv_template_col = st.columns([3, 1])
|
| 602 |
if pricing_source == 'Paydirt DB':
|
| 603 |
if st.button("Load from Paydirt DB"):
|
| 604 |
st.session_state['csv_file'] = load_csv(nfl_reg_salaries)
|
| 605 |
+
st.session_state['pricing_loaded'] = True
|
| 606 |
if 'csv_file' in st.session_state:
|
| 607 |
del st.session_state['csv_file']
|
| 608 |
+
try:
|
| 609 |
+
st.session_state['csv_file']['Salary'] = st.session_state['csv_file']['Salary'].astype(str).str.replace(',', '').astype(int)
|
| 610 |
+
except:
|
| 611 |
+
pass
|
| 612 |
else:
|
| 613 |
with upload_csv_col:
|
| 614 |
csv_file = st.file_uploader("Upload CSV File", type=['csv'])
|
|
|
|
| 627 |
mime="text/csv"
|
| 628 |
)
|
| 629 |
st.session_state['csv_file'] = load_csv(csv_file)
|
| 630 |
+
st.session_state['pricing_loaded'] = True
|
| 631 |
+
try:
|
| 632 |
+
st.session_state['csv_file']['Salary'] = st.session_state['csv_file']['Salary'].astype(str).str.replace(',', '').astype(int)
|
| 633 |
+
except:
|
| 634 |
+
pass
|
| 635 |
|
| 636 |
if st.session_state['pricing_loaded']:
|
| 637 |
if type_var == 'Showdown':
|