Spaces:
Sleeping
Sleeping
File size: 669 Bytes
d75dae7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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)}")
|