cleaner refactor

This commit is contained in:
Lorenze Jay
2024-12-03 12:18:07 -08:00
parent 7e93285df1
commit 8b1aef9e2d
6 changed files with 24 additions and 46 deletions

View File

@@ -10,14 +10,13 @@ class ExcelKnowledgeSource(BaseFileKnowledgeSource):
"""Load and preprocess Excel file content."""
pd = self._import_dependencies()
if isinstance(self.file_path, list):
file_path = self.convert_to_path(self.file_path[0])
else:
file_path = self.convert_to_path(self.file_path)
df = pd.read_excel(file_path)
content = df.to_csv(index=False)
return {file_path: content}
content_dict = {}
for file_path in self.safe_file_paths:
file_path = self.convert_to_path(file_path)
df = pd.read_excel(file_path)
content = df.to_csv(index=False)
content_dict[file_path] = content
return content_dict
def _import_dependencies(self):
"""Dynamically import dependencies."""