Spaces:
Sleeping
Sleeping
| from smolagents import Tool | |
| import pandas as pd | |
| from tabulate import tabulate | |
| class ExcelReader(Tool): | |
| name = 'excel_processor' | |
| description = "excel reading tool, processed files of .xlsx and .xls format." | |
| inputs = { | |
| "file_path": { | |
| "type": "string", | |
| "description": "path to the excel file" | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, file_path: str) -> str: | |
| try: | |
| df = pd.read_excel(file_path) | |
| txt_excel = tabulate(df, headers="keys", tablefmt="github", showindex=False) | |
| return txt_excel | |
| except Exception as e: | |
| return f'Error in reading excel file: {str(e)}' | |