diff --git a/api/core/data_loader/loader/excel.py b/api/core/data_loader/loader/excel.py index 7dd62f5094..08c0462728 100644 --- a/api/core/data_loader/loader/excel.py +++ b/api/core/data_loader/loader/excel.py @@ -36,8 +36,9 @@ class ExcelLoader(BaseLoader): if keys == []: keys = list(map(str, row)) else: - row_dict = dict(zip(keys, row)) + row_dict = dict(zip(keys, list(map(str, row)))) row_dict = {k: v for k, v in row_dict.items() if v} - data.append(json.dumps(row_dict, ensure_ascii=False)) + item = ''.join(f'{k}:{v}\n' for k, v in row_dict.items()) + data.append(item) return [Document(page_content='\n\n'.join(data))] diff --git a/api/core/data_loader/loader/notion.py b/api/core/data_loader/loader/notion.py index 913128d9fe..8235c58cf2 100644 --- a/api/core/data_loader/loader/notion.py +++ b/api/core/data_loader/loader/notion.py @@ -134,6 +134,16 @@ class NotionLoader(BaseLoader): else: value = property_value[type] data[property_name] = value + row_dict = {k: v for k, v in data.items() if v} + row_content = '' + for key, value in row_dict.items(): + if isinstance(value, dict): + value_dict = {k: v for k, v in value.items() if v} + value_content = ''.join(f'{k}:{v} ' for k, v in value_dict.items()) + row_content = row_content + f'{key}:{value_content}\n' + else: + row_content = row_content + f'{key}:{value}\n' + database_content_list.append(row_content) database_content_list.append(json.dumps(data, ensure_ascii=False)) return "\n\n".join(database_content_list)