Convert to CSV

Input Output
  • Any (JSON)
  • Required: Array of Objects (Dataset)
  • Any (JSON) (Passthrough)
  • CSV Data (string)

Summary

Takes an array of objects (a tabular dataset) and converts it into a CSV file.

For example, given the following dataset:

Copy
[
  {
    "Make": "Toyota",
    "Model": "Camry",
    "Year": 2020,
    "Price": 24000
  },
  {
    "Make": "Honda",
    "Model": "Civic",
    "Year": 2019,
    "Price": 22000
  },
  {
    "Make": "Ford",
    "Model": "Mustang",
    "Year": 2021,
    "Price": 27000
  }
]

The following CSV dataset will be generated:

Copy
"Make","Model","Year","Price"
"Toyota","Camry","2020","24000"
"Honda","Civic","2019","22000"
"Ford","Mustang","2021","27000"

Input Object

Copy
{
  "myData": [
    {
      "Make": "Toyota",
      "Model": "Camry",
      "Year": 2020,
      "Price": 24000
    },
    {
      "Make": "Honda",
      "Model": "Civic",
      "Year": 2019,
      "Price": 22000
    },
    {
      "Make": "Ford",
      "Model": "Mustang",
      "Year": 2021,
      "Price": 27000
    }
  ]
}

Output Object

Assumes that you’ve set the “Output Property” name to “myCsvData”.

{
  "myData": [
    {
      "Make": "Toyota",
      "Model": "Camry",
      "Year": 2020,
      "Price": 24000
    },
    {
      "Make": "Honda",
      "Model": "Civic",
      "Year": 2019,
      "Price": 22000
    },
    {
      "Make": "Ford",
      "Model": "Mustang",
      "Year": 2021,
      "Price": 27000
    }
  ],
  "myCsvData": "\"Make\",\"Model\",\"Year\",\"Price\"\n\"Toyota\",\"Camry\",\"2020\",\"24000\"\n\"Honda\",\"Civic\",\"2019\",\"22000\"\n\"Ford\",\"Mustang\",\"2021\",\"27000\""}

Properties

Name

Type

Templatable

Notes

Field Delimiter

Choice:

  • Comma (,)

  • Tab (\t)

  • Pipe (|)

  • Semicolon (;)

  • Other

No

Select the field delimiter character.

For CSV files, this is usually a comma.

Custom Delimiter

Text

No

Only visible if Field Delimiter is “Other”. Enter one or more characters to use as the field delimiter.

Line Delimiter

Choice

  • CRLF (\r\n)

  • LF (\n)

No

Choose whether you want Windows (CRLF) or Unix (LF) style line endings.

Input Array

Text

Yes

Enter an expression pointing to an array of objects to use as the input for the CSV data. Use the “array” function to cast the data as an array.

Example:

{{ input.myData | array }}

Output Property

Text

No

Specify the name of the property to store the CSV data in.