Skip to content

Function: parseCsv() ​

parseCsv<T>(content, schema, options?): StaticDecode<T>[]

Parse the CSV string according to the given schema

Type Parameters ​

Type Parameter
T extends TCsvSchema

Parameters ​

ParameterTypeDescription
contentstringA string of CSV file content
schemaTOutput schema mapping of each row
options?ParseOptions-

Returns ​

StaticDecode<T>[]

An array of given schema

Throws ​

If fail to parse the schema

Example ​

ts
const output = parseCsv('ID,Name\n1,A\n2,B\n', schema);

Defined in ​

src/parser/parse-csv.ts:39

Released under the MIT License.