ClarzW commited on
Commit
c672be8
·
verified ·
1 Parent(s): 2fb3cdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -27,11 +27,6 @@ def save_data(df):
27
  if 'expenses' not in st.session_state:
28
  st.session_state['expenses'] = load_data()
29
 
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']
@@ -46,15 +41,12 @@ if uploaded_file is not None:
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")
 
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
  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
 
45
  else:
46
  st.error("File type is not supported. Please upload a CSV file.")
47
 
48
+ rerun_button = st.button("Rerun")
49
+ if rerun_button:
 
 
50
  st.rerun()
51
 
52
  st.title("Expense Tracker")