Freddolin commited on
Commit
f931a9d
·
verified ·
1 Parent(s): 464e3d9

Update tools/excel_tool.py

Browse files
Files changed (1) hide show
  1. tools/excel_tool.py +10 -3
tools/excel_tool.py CHANGED
@@ -1,8 +1,15 @@
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}"
 
 
 
1
  import pandas as pd
2
+ import requests
3
+ from io import BytesIO
4
 
5
+ def analyze_excel(path_or_url: str) -> str:
6
  try:
7
+ if path_or_url.startswith("http"):
8
+ response = requests.get(path_or_url)
9
+ df = pd.read_excel(BytesIO(response.content))
10
+ else:
11
+ df = pd.read_excel(path_or_url)
12
  except Exception as e:
13
  return f"Error reading Excel file: {e}"
14
+
15
+ return f"Loaded sheet with shape {df.shape} and columns: {', '.join(df.columns)}"