Skip to main content

$$csv

Converts an array of objects/arrays to a CSV string

Usage​

{
"$$csv": [ /* values */ ],
"no_headers": false,
"force_quote": false,
"separator": ",",
"names": [ /* names */]
}
"$$csv([no_headers],[force_quote],[separator],[names]):{input}"

Returns​

string

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
no_headersbooleanfalse/truefalseWhether to include object keys as headers (taken from first object if no names)
force_quotebooleanfalse/truefalseWhether to quote all the values
separatorstringfalse/true","Use an alternative field separator
namesstring[](Names taken from the first object)Names of fields to extract into csv if objects (will be used as the header row, unless no_headers)

Examples​

Input

Definition

Output

[
{
"a": "A",
"b": 1
},
{
"a": "C",
"b": 2
}
]
{
"$$csv": "$"
}
a,b
A,1
C,2
[
{
"a": "A",
"b": 1
},
{
"a": "C",
"b": 2
}
]
{
"$$csv": "$",
"no_headers": true
}
A,1
C,2
[
["1","2"],
["3","4"]
]
{
"$$csv": "$"
}
1,2
3,4
[
["1","2"],
["3","4"]
]
{
"$$csv": "$",
"names": ["a","b"]
}
a,b
1,2
3,4
[
{
"a": "A",
"b": 1
},
{
"a": "C",
"b": 2
}
]
"$$csv:$"
a,b
A,1
C,2
[
{
"a": "A",
"b": 1
},
{
"a": "C",
"b": 2
}
]
"$$csv(true):$"
A,1
C,2
[
{
"a": "A",
"b": 1
},
{
"a": "C",
"b": 2
}
]
"$$csv(true,true):$"
"A","1"
"C","2"