$$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​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
no_headers | boolean | false /true | false | Whether to include object keys as headers (taken from first object if no names ) |
force_quote | boolean | false /true | false | Whether to quote all the values |
separator | string | false /true | "," | Use an alternative field separator |
names | string[] | (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"