MCPcopy Index your code
hub / github.com/simstudioai/sim / parseFileRows

Function parseFileRows

apps/sim/lib/table/import.ts:495–509  ·  view source on GitHub ↗
(
  buffer: Buffer,
  fileName: string,
  contentType?: string
)

Source from the content-addressed store, hash-verified

493 * the MIME content type. Throws on unsupported formats so callers fail fast.
494 */
495export async function parseFileRows(
496 buffer: Buffer,
497 fileName: string,
498 contentType?: string
499): Promise<{ headers: string[]; rows: Record<string, unknown>[] }> {
500 const ext = fileName.split('.').pop()?.toLowerCase()
501 if (ext === 'json' || contentType === 'application/json') {
502 return parseJsonRows(buffer)
503 }
504 if (ext === 'csv' || ext === 'tsv' || contentType === 'text/csv') {
505 const delimiter = ext === 'tsv' ? '\t' : ','
506 return parseCsvBuffer(buffer, delimiter)
507 }
508 throw new Error(`Unsupported file format: "${ext ?? fileName}". Supported: csv, tsv, json`)
509}

Callers 1

executeFunction · 0.90

Calls 2

parseJsonRowsFunction · 0.85
parseCsvBufferFunction · 0.85

Tested by

no test coverage detected