witchEverly commited on
Commit
cf6bcfb
·
verified ·
1 Parent(s): d51e5d9

Update app_utils.py

Browse files
Files changed (1) hide show
  1. app_utils.py +31 -4
app_utils.py CHANGED
@@ -40,7 +40,28 @@ def init_model():
40
  st.error(f"Error occurred during model initialization: {e}")
41
 
42
 
43
- # Function to store the user data to a CSV file
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  def save_user_data(first_name, last_name, email, phone):
45
  """
46
  Function to store the user data to a CSV file
@@ -56,9 +77,15 @@ def save_user_data(first_name, last_name, email, phone):
56
  if csv_file.exists():
57
  df = pd.read_csv(csv_file)
58
  else:
59
- df = pd.DataFrame(columns=["First Name", "Last Name", "Email", "Phone Number"])
60
- new_data = {"First Name": first_name, "Last Name": last_name, "Email": email, "Phone Number": phone}
61
- df = df.append(new_data, ignore_index=True)
 
 
 
 
 
 
62
  df.to_csv(csv_file, index=False)
63
  return None
64
 
 
40
  st.error(f"Error occurred during model initialization: {e}")
41
 
42
 
43
+ # # Function to store the user data to a CSV file
44
+ # def save_user_data(first_name, last_name, email, phone):
45
+ # """
46
+ # Function to store the user data to a CSV file
47
+
48
+ # :param first_name: str - First name of the user
49
+ # :param last_name: str - Last name of the user
50
+ # :param email: str - Email of the user
51
+ # :param phone: str - Phone number of the user
52
+ # :return: None
53
+ # """
54
+ # csv_file = Path("./user_data/user_data.csv")
55
+ # # Check if the file exists and create a DataFrame accordingly
56
+ # if csv_file.exists():
57
+ # df = pd.read_csv(csv_file)
58
+ # else:
59
+ # df = pd.DataFrame(columns=["First Name", "Last Name", "Email", "Phone Number"])
60
+ # new_data = {"First Name": first_name, "Last Name": last_name, "Email": email, "Phone Number": phone}
61
+ # df = df.append(new_data, ignore_index=True)
62
+ # df.to_csv(csv_file, index=False)
63
+ # return None
64
+
65
  def save_user_data(first_name, last_name, email, phone):
66
  """
67
  Function to store the user data to a CSV file
 
77
  if csv_file.exists():
78
  df = pd.read_csv(csv_file)
79
  else:
80
+ df = pd.DataFrame(columns=["First Name", "Last Name",
81
+ "Email", "Phone Number"])
82
+
83
+ # Add and save new user data.
84
+ new_data = pd.DataFrame({"First Name": [first_name],
85
+ "Last Name": [last_name],
86
+ "Email": [email],
87
+ "Phone Number": [phone]})
88
+ df = pd.concat([df, new_data], ignore_index=True)
89
  df.to_csv(csv_file, index=False)
90
  return None
91