$$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​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | array | Yes | Array of objects/arrays | |
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 | "," | Use an alternative field separator | |
names | string[] | null | 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(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"