Delete tools/file/analyze_excel_file.py
Browse files
tools/file/analyze_excel_file.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
from langchain_core.tools import tool
|
| 2 |
-
import pandas as pd
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
@tool
|
| 6 |
-
def analyze_excel_file(file_path: str, query: str) -> str:
|
| 7 |
-
"""
|
| 8 |
-
Analyze an Excel file using pandas and answer a question about it.
|
| 9 |
-
Args:
|
| 10 |
-
file_path (str): the path to the Excel file.
|
| 11 |
-
query (str): Question about the data
|
| 12 |
-
"""
|
| 13 |
-
try:
|
| 14 |
-
# Read the Excel file
|
| 15 |
-
df = pd.read_excel(file_path)
|
| 16 |
-
|
| 17 |
-
# Run various analyses based on the query
|
| 18 |
-
result = (
|
| 19 |
-
f"Excel file loaded with {len(df)} rows and {len(df.columns)} columns.\n"
|
| 20 |
-
)
|
| 21 |
-
result += f"Columns: {', '.join(df.columns)}\n\n"
|
| 22 |
-
|
| 23 |
-
# Add summary statistics
|
| 24 |
-
result += "Summary statistics:\n"
|
| 25 |
-
result += str(df.describe())
|
| 26 |
-
|
| 27 |
-
return result
|
| 28 |
-
|
| 29 |
-
except Exception as e:
|
| 30 |
-
return f"Error analyzing Excel file: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|