Freddolin's picture
Update tools/excel_tool.py
f931a9d verified
raw
history blame
483 Bytes
import pandas as pd
import requests
from io import BytesIO
def analyze_excel(path_or_url: str) -> str:
try:
if path_or_url.startswith("http"):
response = requests.get(path_or_url)
df = pd.read_excel(BytesIO(response.content))
else:
df = pd.read_excel(path_or_url)
except Exception as e:
return f"Error reading Excel file: {e}"
return f"Loaded sheet with shape {df.shape} and columns: {', '.join(df.columns)}"