Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,6 +30,9 @@ if 'expenses' not in st.session_state:
|
|
| 30 |
if 'file_uploaded' not in st.session_state:
|
| 31 |
st.session_state['file_uploaded'] = False
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
# Add categories as required (TO-DO: Add input to append to this list? Might be too complicated for 30 minutes)
|
| 34 |
categories = ['Food', 'Transport', 'Bills', 'Entertainment', 'Other']
|
| 35 |
|
|
@@ -43,15 +46,15 @@ if uploaded_file is not None:
|
|
| 43 |
st.session_state['expenses']['Date'] = pd.to_datetime(st.session_state['expenses']['Date']) # Ensure 'Date' is datetime
|
| 44 |
save_data(st.session_state['expenses']) # Ensures the HuggingFace storage contains this version
|
| 45 |
st.success("CSV file successfully uploaded!")
|
| 46 |
-
st.session_state['
|
| 47 |
|
| 48 |
else:
|
| 49 |
st.error("File type is not supported. Please upload a CSV file.")
|
| 50 |
|
| 51 |
# Check if a file has been uploaded
|
| 52 |
-
if st.session_state['file_uploaded']:
|
| 53 |
# Reset the flag to avoid continuous reruns
|
| 54 |
-
st.session_state['
|
| 55 |
st.rerun()
|
| 56 |
|
| 57 |
st.title("Expense Tracker")
|
|
|
|
| 30 |
if 'file_uploaded' not in st.session_state:
|
| 31 |
st.session_state['file_uploaded'] = False
|
| 32 |
|
| 33 |
+
if 'rerun' not in st.session_state:
|
| 34 |
+
st.session_state['rerun'] = False
|
| 35 |
+
|
| 36 |
# Add categories as required (TO-DO: Add input to append to this list? Might be too complicated for 30 minutes)
|
| 37 |
categories = ['Food', 'Transport', 'Bills', 'Entertainment', 'Other']
|
| 38 |
|
|
|
|
| 46 |
st.session_state['expenses']['Date'] = pd.to_datetime(st.session_state['expenses']['Date']) # Ensure 'Date' is datetime
|
| 47 |
save_data(st.session_state['expenses']) # Ensures the HuggingFace storage contains this version
|
| 48 |
st.success("CSV file successfully uploaded!")
|
| 49 |
+
st.session_state['file_uploaded'] = True
|
| 50 |
|
| 51 |
else:
|
| 52 |
st.error("File type is not supported. Please upload a CSV file.")
|
| 53 |
|
| 54 |
# Check if a file has been uploaded
|
| 55 |
+
if st.session_state['file_uploaded'] and not st.session_state['rerun']:
|
| 56 |
# Reset the flag to avoid continuous reruns
|
| 57 |
+
st.session_state['rerun'] = True
|
| 58 |
st.rerun()
|
| 59 |
|
| 60 |
st.title("Expense Tracker")
|