Skip to main content
Version: v0.0.4

Function: parseCsv()

parseCsv(content): string[][]

Parse RFC-4180 CSV content into rows of fields (the .rows of parseCsvRows). Lenient: a stray mid-field quote is literal, so a malformed quote never silently swallows subsequent rows.

Parameters

content

string

The raw CSV text.

Returns

string[][]

The rows, each an array of field strings (untrimmed).

Example

import { parseCsv } from "@cosyte/terminology";

parseCsv('a,b\n"x,y","z""q"'); // => [["a", "b"], ["x,y", 'z"q']]