Spaces:
Sleeping
Sleeping
Update tools/excel_tool.py
Browse files- 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(
|
4 |
try:
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
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)}"
|