Skip to main content

$$csv

Converts an array of objects/arrays to a CSV string

Usage​

{ 
"$$csv": /* Array of objects/arrays */,
"no_headers": false /* boolean */,
"force_quote": false /* boolean */,
"separator": "," /* string */,
"names": /* string[] */
}
"$$csv([no_headers],[force_quote],[separator],[names]):{input}"
note

Concrete values in the usage example are default values.

Returns​

string - CSV

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of objects/arrays
no_headersbooleanfalse/truefalseWhether to include object keys as headers (taken from first object if no names)
force_quotebooleanfalse/truefalseWhether to quote all the values
separatorstring","Use an alternative field separator
namesstring[]nullNames 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(true):$"
A,1
C,2

[
{
"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": "$",
"names": [
"a",
"b"
]
}
a,b
1,2
3,4

[
[
1,
2
],
[
3,
4
]
]
{
"$$csv": "$"
}
1,2
3,4

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