dschandra commited on
Commit
7ad0ad6
·
verified ·
1 Parent(s): 3e88fb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -4,10 +4,25 @@ import pandas as pd
4
  # Load menu from Excel file
5
  def load_menu(file_path="menu.xlsx"):
6
  """
7
- Load menu data from an Excel file.
8
  """
9
  menu_df = pd.read_excel(file_path)
10
- menu = menu_df.to_dict(orient="records")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  return menu
12
 
13
  # Initialize menu and cart
 
4
  # Load menu from Excel file
5
  def load_menu(file_path="menu.xlsx"):
6
  """
7
+ Load menu data from an Excel file dynamically based on column headers.
8
  """
9
  menu_df = pd.read_excel(file_path)
10
+
11
+ # Automatically normalize column names
12
+ columns = menu_df.columns.str.strip() # Trim leading/trailing spaces
13
+ name_column = [col for col in columns if "name" in col.lower()][0]
14
+ price_column = [col for col in columns if "price" in col.lower()][0]
15
+ description_column = [col for col in columns if "description" in col.lower()][0]
16
+ image_column = [col for col in columns if "image" in col.lower()][0]
17
+
18
+ menu = []
19
+ for _, row in menu_df.iterrows():
20
+ menu.append({
21
+ "name": row[name_column],
22
+ "price": row[price_column],
23
+ "description": row[description_column],
24
+ "image": row[image_column]
25
+ })
26
  return menu
27
 
28
  # Initialize menu and cart