Freddolin commited on
Commit
9876236
·
verified ·
1 Parent(s): 075eaf6

Update tools/excel_tool.py

Browse files
Files changed (1) hide show
  1. tools/excel_tool.py +6 -7
tools/excel_tool.py CHANGED
@@ -1,9 +1,8 @@
1
  import pandas as pd
2
 
3
- def analyze_excel(filepath: str) -> str:
4
- df = pd.read_excel(filepath)
5
- # Summing up all numeric food items if 'category' exists
6
- if 'category' in df.columns and 'amount' in df.columns:
7
- food_sales = df[df['category'].str.lower() == 'food']
8
- return f"{food_sales['amount'].sum():.2f}"
9
- return "0.00"
 
1
  import pandas as pd
2
 
3
+ def analyze_excel(file_path: str) -> str:
4
+ try:
5
+ df = pd.read_excel(file_path)
6
+ return df.to_string(index=False)
7
+ except Exception as e:
8
+ return f"Error reading Excel file: {e}"