Skip to main content
Version: 8.8 (unreleased)

CSV connector

The CSV connector reads CSV files and converts JSON data to CSV format for document or text use.

Create a CSV connector task

You can apply a connector to a task or event via the append menu. For example:

  • From the canvas: Select an element and click the Change element icon to change an existing element, or use the append feature to add a new element to the diagram.
  • From the properties panel: Navigate to the Template section and click Select.
  • From the side palette: Click the Create element icon.

change element

After you have applied a connector to your element, follow the configuration steps or see using connectors to learn more.

Operations

The CSV connector supports operations to read and write CSVs.

Read CSV

Reads a CSV from a text or a document and converts it into an array of JSON records.

PropertyTypeDescriptionRequiredExample
DataDocument or StringThe CSV data as a document or textYesExample CSV
DelimiterStringThe delimiter used to separate each columnNoDefaults to ,
Skip header recordBooleanWhether to skip the first row (header) in the recordsNoDefaults to true
HeadersArray of stringsUsed when no header is present or to override column namesNoDefaults to []. Example: ["name","cost","count"]
Row typeStringDetermines the structure of the result records.NoDefaults to Object. Either Object or Array.

Example CSV Data input:

product,quantity,price
Wireless Mouse,25,29.99
Office Chair,8,149.50n
USB Cable,100,12.99
Monitor Stand,15,45.00
Desk Lamp,32,24.95
info

To pass the CSV Data as a FEEL string, end lines with \r\n. This is the default line separator when reading CSV files. For example:

="product,quantity,price\r\nWireless Mouse,25,29.99\r\nOffice Chair,8,149.50\r\nUSB Cable,100,12.99\r\nMonitor Stand,15,45.00\r\nDesk Lamp,32,24.95"

Example output for row type Object

{
"records": [
{ "product": "Wireless Mouse", "quantity": "25", "price": "29.99" },
{ "product": "Office Chair", "quantity": "8", "price": "149.50" },
{ "product": "USB Cable", "quantity": "100", "price": "12.99" },
{ "product": "Monitor Stand", "quantity": "15", "price": "45.00" },
{ "product": "Desk Lamp", "quantity": "32", "price": "24.95" }
]
}

Based on the Object example above, you can access the CSV data in your result expression for further processing:

{
sum: sum(for r in records return number(r.quantity))
}

Example output for row type Array

{
"records": [
["Wireless Mouse", "25", "29.99"],
["Office Chair", "8", "149.50"],
["USB Cable", "100", "12.99"],
["Monitor Stand", "15", "45.00"],
["Desk Lamp", "32", "24.95"]
]
}

Based on the Array example above, you can access the CSV data in your result expression for further processing:

{
sum: sum(for r in records return number(r[2]))
}

Write CSV

Takes an array of JSON objects and creates a CSV from it. The result can either be stored as a document for further processing (e.g., uploading) or returned as a string.

PropertyTypeDescriptionRequiredExample
DataArrayThe CSV data as an array of objects or arraysYesObject and Array example.
Create documentBooleanIf true the connector will store the CSV document in Camunda and returns a reference. If false the CSV will be returned as a string.NoDefaults to false
DelimiterStringThe delimiter used to separate each column.NoDefaults to ,
Skip header recordBooleanWhether to include the first row in the records or not.NoDefaults to true
HeadersArray of stringsCan be used when there is no header record present in the record or to change the column names if there is a header record.NoDefaults to []. Example: ["name","cost","count"]. Needs to be specified when using object-based arrays as the Data input.
Row typeStringDetermines how the result records object will be structured.NoDefaults to Object. Either Object or Array.

Example for an array-based Data input

[
["Wireless Mouse", "25", "29.99"],
["Office Chair", "8", "149.50n"],
["USB Cable", "100", "12.99"],
["Monitor Stand", "15", "45.00"],
["Desk Lamp", "32", "24.95"]
]

Example for an object-based Data input

{
"records": [
{ "product": "Wireless Mouse", "quantity": "25", "price": "29.99" },
{ "product": "Office Chair", "quantity": "8", "price": "149.50" },
{ "product": "USB Cable", "quantity": "100", "price": "12.99" },
{ "product": "Monitor Stand", "quantity": "15", "price": "45.00" },
{ "product": "Desk Lamp", "quantity": "32", "price": "24.95" }
]
}
info

Headers must be specified when using object-based arrays as the Data input when writing a CSV. The Headers must match the property names of the objects. For the example above, one would provide the following value for Headers:

=["product", "quantity", "price"]

Example output for a CSV returned a string

{
"content": "Wireless Mouse,25,29.99\r\nOffice Chair,8,149.50n\r\nUSB Cable,100,12.99\r\nMonitor Stand,15,45.00\r\nDesk Lamp,32,24.95\r\n"
}

Example output for a CSV stored in a document

{
"document": {
"storeId": "in-memory",
"documentId": "8b54b413-b847-4650-b445-de963d5c506d",
"contentHash": "ed0f7ad835669698a108a32b2a99e89e4f5aea84127fde68df4248b11197b0e5",
"metadata": {
"contentType": "text/csv",
"size": 114,
"fileName": "8b54b413-b847-4650-b445-de963d5c506d"
},
"camunda.document.type": "camunda"
}
}