Skip to main content

$$csvparse

Converts a CSV string into an array of objects/arrays

Usage​

{ 
"$$csvparse": /* csv contents */,
"no_headers": false /* boolean */,
"separator": "," /* string */,
"names": /* array */
}
"$$csvparse([no_headers],[separator],[names]):{input}"
note

Concrete values in the usage example are default values.

Returns​

object[]

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimarystringYescsv contents
no_headersbooleanfalse/truefalseWhether to treat the first row as object keys
separatorstring","Use an alternative field separator
namesarraynullNames of fields of input arrays (by indices) or objects (can sift if provided less names than there are in the objects provided)

Examples​

Input

Definition

Output

a
","
"$$csvparse:$"
[
{
"a": ","
}
]
a
""""
"$$csvparse:$"
[
{
"a": "\""
}
]
1,2
3,4
"$$csvparse(true):$"
[
[
"1",
"2"
],
[
"3",
"4"
]
]
a
","
{
"$$csvparse": "$"
}
[
{
"a": ","
}
]
a
""""
{
"$$csvparse": "$"
}
[
{
"a": "\""
}
]
1,2
3,4
{
"$$csvparse": "$",
"no_headers": true
}
[
[
"1",
"2"
],
[
"3",
"4"
]
]