Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| from smolagents import Tool | |
| class ExcelReaderTool(Tool): | |
| name = "excel_reader" | |
| description = "Extract Excel file content. Supported file extensions: .xls, .xlsx, .xlsb, .xlsm, .odf, .ods, .odt" | |
| inputs = { | |
| "file_path": { | |
| "type": "string", | |
| "description": "Path to the Excel file", | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, file_path) -> str: | |
| try: | |
| df = pd.read_excel(file_path) | |
| print(f"Describe Excel file:\n {df.describe()}") | |
| return df.to_json() | |
| except Exception as e: | |
| print(f"Error: processing Excel file: {str(e)}") | |