ClarzW commited on
Commit
c4cdec2
·
verified ·
1 Parent(s): 6be623c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -27,6 +27,8 @@ def save_data(df):
27
  if 'expenses' not in st.session_state:
28
  st.session_state['expenses'] = load_data()
29
 
 
 
30
 
31
  # Add categories as required (TO-DO: Add input to append to this list? Might be too complicated for 30 minutes)
32
  categories = ['Food', 'Transport', 'Bills', 'Entertainment', 'Other']
@@ -41,11 +43,14 @@ if uploaded_file is not None:
41
  st.session_state['expenses']['Date'] = pd.to_datetime(st.session_state['expenses']['Date']) # Ensure 'Date' is datetime
42
  save_data(st.session_state['expenses']) # Ensures the HuggingFace storage contains this version
43
  st.success("CSV file successfully uploaded!")
44
- st.rerun()
45
 
46
  else:
47
  st.error("File type is not supported. Please upload a CSV file.")
48
-
 
 
 
49
 
50
  st.title("Expense Tracker")
51
 
 
27
  if 'expenses' not in st.session_state:
28
  st.session_state['expenses'] = load_data()
29
 
30
+ if 'rerun' not in st.session_state:
31
+ st.session_state['rerun'] = 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']
 
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['rerun'] = True
47
 
48
  else:
49
  st.error("File type is not supported. Please upload a CSV file.")
50
+
51
+ if st.session_state['rerun']:
52
+ st.session_state['rerun'] = False
53
+ st.rerun()
54
 
55
  st.title("Expense Tracker")
56