MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / processCSV

Function processCSV

packages/baseai/src/utils/memory/get-document-content.ts:149–169  ·  view source on GitHub ↗

* Processes the content of a CSV file and returns the processed content. * * The processed content is a string where each row is prepended with the header row. * * @param csvContent - The content of the CSV file as a string. * @returns The processed content of the CSV file.

(csvContent: string)

Source from the content-addressed store, hash-verified

147 * @returns The processed content of the CSV file.
148 */
149function processCSV(csvContent: string): string {
150 // Split the content into rows
151 const rows = csvContent.split('\n');
152
153 // Extract the header row
154 const header = rows[0].replace('\r', '');
155
156 // Process each data row and join them into a single string
157 const processedContent = rows
158 .slice(1)
159 .map(row => {
160 // Skip empty rows and rows with only commas
161 if (row.trim() === '' || /^[,]+$/.test(row.trim())) {
162 return '';
163 }
164 return header + '\n' + row;
165 })
166 .join('\n\n');
167
168 return processedContent;
169}

Callers 2

processCsvFileFunction · 0.85
processXlsFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected