CSVWrite

Description

CSV Write generates a comma-separated string with the input payload as input. It is not meant to create CSV files for further processing as writing the output to a file will not append, but overwrite it. If you want to populate a CSV file appending new lines of data after every incoming sensor data, you can use the File Write component and follow the example there.

The input payload can be an array of JSON arrays or an array of JSON objects. Otherwise, it will be converted to a string and output as a CSV with one line and one column.

Input PayloadExample
JSON array payload example[[123, "abc", "xxx"], [456, "def", "yyy"], [789, "hij", "zzz"]]
JSON Object payload example[{"field1":123, "field2":"abc", "field3":"xxx"}, {"field1":456, "field2":"def", "field3":"yyy"}, {"field1":789, "field2":"hij", "field3":"zzz"}]

The "Output" property allows you to select the output destination as file or payload.

Output payloadDescription
When you choose "File" for the "Output Destination" propertyThe generated CSV is written to a file and the output payload passes the input payload. (Pass-through.)
When you choose "Payload" for the "Output to" propertyPut the generated CSV byte sequence into the output payload.

Component Properties

NameRequiredDescription
OutputTrueSpecify either File or Payload as the output destination. cp.Output is set to either "Payload" or "File".
FilenameFalseSpecify the file name for file output
EncodingFalseSpecify the encoding of the file output (utf-8, shift_jis, euc-jp,iso-2022-jp)