MCPcopy Create free account
hub / github.com/experdot/pointer / toCsv

Function toCsv

src/renderer/src/features/export/plugins/editors/csvEditor.tsx:56–68  ·  view source on GitHub ↗

* Convert table data to CSV string

(headers: string[], rows: string[][])

Source from the content-addressed store, hash-verified

54 * Convert table data to CSV string
55 */
56function toCsv(headers: string[], rows: string[][]): string {
57 const escapeCell = (cell: string): string => {
58 if (cell.includes(',') || cell.includes('"') || cell.includes('\n')) {
59 return `"${cell.replace(/"/g, '""')}"`
60 }
61 return cell
62 }
63
64 const headerLine = headers.map(escapeCell).join(',')
65 const dataLines = rows.map((row) => row.map(escapeCell).join(','))
66
67 return [headerLine, ...dataLines].join('\n')
68}
69
70/**
71 * CSV Table Editor Component

Callers 1

CsvTableEditorComponentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected