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

Function detectDelimiter

apps/sim/lib/file-parsers/csv-preview-slice.ts:31–38  ·  view source on GitHub ↗

* Detects the CSV delimiter from a header line by frequency. Mirrors the file viewer's * client-side heuristic (comma / tab / semicolon) so server-streamed previews match.

(line: string)

Source from the content-addressed store, hash-verified

29 * client-side heuristic (comma / tab / semicolon) so server-streamed previews match.
30 */
31function detectDelimiter(line: string): string {
32 const commaCount = (line.match(/,/g) || []).length
33 const tabCount = (line.match(/\t/g) || []).length
34 const semiCount = (line.match(/;/g) || []).length
35 if (tabCount > commaCount && tabCount > semiCount) return '\t'
36 if (semiCount > commaCount) return ';'
37 return ','
38}
39
40function cell(value: unknown): string {
41 return truncate(String(value ?? ''), MAX_CELL_LENGTH)

Callers 1

getCsvPreviewSliceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected