Skip to content

Function: parseCsv()

parseCsv<T>(content, schema): 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

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:32

Released under the MIT License.