CSV Parser component

A utility component that parses the specified input string in comma-separated values (CSV) format, returning an array of objects representing the parsed rows. In addition to CSV it also supports tab-separated values (TSV) and arbitrary delimiter-separated values (DSV) formats. This operation is the reverse of CSV Formatter.

https://kroki.io/svgbob/svg/eNpT0NPFAHpcCjUKQOAcHKYQkFhUnFoE4tUARTHV1nDp5itk5hWUloDUKOSXloCY-bog4eT8nNLcvGIFOAMorKCOaYY6AP73H_c=

In-ports

input String Input data specified as string in comma-separated values (CSV) format.

columns Array An Array of strings that represents the headers of the columns in the input CSV string. The order of headers will determine the order of columns in the output array.

Out-ports

output Array Outputs an array of rows (array of arrays of values) or array of objects.

columns Array An Array of strings that represents the headers of the columns in output array. its useful to get the headers as a separate array when the provided input string contains headers.

Overview

CSV Parser component parses input string in comma-separated values format and generates an output in JSON format. The string is assumed to be RFC4180-compliant. This component needs to know the list of column names in order to generate the attributes on the returned objects. The columns can be specified in the first line of the input CSV string, or provided as a separate array on the columns input port.

note

The values themselves in the CSV (and other compatible formats) are always strings; they will not be automatically converted to numbers. You can do the conversion after parsing the input using the transformations.

You can specify the input format in the Settings.

Data examples

An example of a CSV input string:

Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38

This input will produce the following output:

[
{ "Year": "1997", "Make": "Ford", "Model": "E350", "Length": "2.34" },
{ "Year": "2000", "Make": "Mercury", "Model": "Cougar", "Length": "2.38" }
]

The same data represented as an array of arrays:

[
["Year", "Make", "Model", "Length"],
["1997", "Ford", "E350", "2.34"],
["2000", "Mercury", "Cougar", "2.38"]
]

Settings

Input format

Specifies the input format. Choose from the most common CSV (comma-separated values), TSV (tab-separated values ), or set DSV (delimiter-separated values) and specify custom delimiter.

Delimiter

Custom delimiter symbol. For example, you can parse values separated by |, the vertical bar character.

Output format

Specifies the output format as an array of arrays or an array of objects.

Headings in the first row

Specify if the first row in the input array should be used as the source column headers. Alternatively, you can pass them as an array to columns input port. If headers are not provided, the component won't be able to produce an array of objects as an output.

Related

CSV Formatter HTTP JSON String