Freddolin commited on
Commit
9779920
·
verified ·
1 Parent(s): 68f7e32

Create tools/excel_tool.py

Browse files
Files changed (1) hide show
  1. tools/excel_tool.py +9 -0
tools/excel_tool.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
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"