Spaces:
Sleeping
Sleeping
Download tools/excel_tool.py from Freddolin/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 483 Bytes
-
https://huggingface.co/spaces/Freddolin/Final_Assignment_Template/resolve/2d42395f3eb30a70ce96fa3ecae016cd0373c63d/tools/excel_tool.py
- Command line
-
hf download hf://spaces/Freddolin/Final_Assignment_Template@2d42395f3eb30a70ce96fa3ecae016cd0373c63d/tools/excel_tool.py
-
curl -L -o excel_tool.py https://huggingface.co/spaces/Freddolin/Final_Assignment_Template/resolve/2d42395f3eb30a70ce96fa3ecae016cd0373c63d/tools/excel_tool.py
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)}" | |