mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* perf: read file worker * fix: Http node url input * fix: htm2md * fix: html2md * fix: ts * perf: Problem classification increases the matching order * feat: tool response answer
22 lines
581 B
TypeScript
22 lines
581 B
TypeScript
import Papa from 'papaparse';
|
|
import { ReadRawTextByBuffer, ReadFileResponse } from '../type';
|
|
import { readFileRawText } from './rawText';
|
|
|
|
// 加载源文件内容
|
|
export const readCsvRawText = async (params: ReadRawTextByBuffer): Promise<ReadFileResponse> => {
|
|
const { rawText } = readFileRawText(params);
|
|
|
|
const csvArr = Papa.parse(rawText).data as string[][];
|
|
|
|
const header = csvArr[0];
|
|
|
|
const formatText = header
|
|
? csvArr.map((item) => item.map((item, i) => `${header[i]}:${item}`).join('\n')).join('\n')
|
|
: '';
|
|
|
|
return {
|
|
rawText,
|
|
formatText
|
|
};
|
|
};
|