CSV File Write

Description

CSVFileWrite generates CSV with the input payload as input.

The input payload (cv.Payload) accepts input as an array of JSON arrays or an array of JSON Objects. Otherwise, it converts it to a string and outputs it as a one-line, one-column CSV file.

Input payloadExample
Example of JSON array payload[[123, "foo", "bar"], [456, "jane", "doe"], [789, "john", "doe"]]
Example of JSON Object payload[{"field1": 123, "field2": "abc", "field3": "xxx"}, {"field1": 456, "field2": "def", "field3": "yyy"}, {"field1": 789, " field2": "hij", "field3": "zzz"}]

component properties

Property nameDescription
File NameSpecify the file name in case of file output
AppendIf true, appends data to the file if it already exists; if false, overwrites the file
Output KeysIf the input payload is a JSON Object, list the field names to be output in the order you want them to be output, separated by commas.
EncodingSpecify the encoding of the file output.

If the file path is not specified, the file is saved in actmgr/data. For how to refer to a file path, refer to "this part"File Path Handling.

How to use the Output Keys

The output keys specify the order, in which the data will be written to the CSV if you use keys.

For example, when the payload of JSON Object is as follows

[{"field1": 123, "field2": "abc", "field3": "xxx"}, {"field1": 456, "field2": "def", "field3": "yyy"}, {"field1": 789, "field2": "hij", "field3":" zzz"}]

and you specify field3, field1 as the output field order, the CSV output will be:

xxx,123

yyyy,456

zzz,789