list-to-csv - Export Data to CSV (DEPRECATED)
This feature is deprecated. It was used actively in IM 1.18.x and older. It is kept now only for compatibility reasons.
This component is used to create CSV formatted file from List<Map<Object,Object>>. The data source can be another PFX component (e.g. jsonToList
, xmlToList
) and loaded records can be resent to another Camel route. The attributes id
 and outputUri
 are required. The component marshals List<Map<Object, Object>>
 with dataFormat
 usage if a custom setting is required; or simply specify a parameter delimiter which is used as a column delimiter in the resulting CSV file. In case that the first row with a header is required, you can specify the header parameter which is a list of comma separated column names (order is preserved). If you specify the header but in some cases you do not want to put it to the file (e.g. when appending to the same file), you can switch it off by setting headerDisabled=true
. The component also supports mapping via the mapper parameter which can be used for an additional conversion or extending columns with a Groovy or simple expression.
Attributes | Description | Required? |
---|---|---|
| ID of the component used for route name. | no |
| Target route of the PFX component where the result will be sent. | yes |
| Name of the bean with a definition of the CSV file in CsvDataFormat. | no |
| Reference to the mapper bean for additional renaming of columns or transformation. | no |
| Size of the batch. | no |
| Timeout. | no |
| If set to 'true', the resulting CSV will not contain the first line with a header. | no |
| Comma separated list of names for columns. The order will be preserved. | no |
| Column delimiter. | no |
| Enables a dynamic header (i.e. generated during export to CSV) The header is generated from keys of the first map line from the list of exported lines. | no |
Example of use in camel-context.xml:
<pfx:jsonToList id="jsonToListCsvMapper">
<pfx:listToCsv delimiter=";" header="country,sku,updatedDate,price,manufacturer"
outputUri="mock:result" mapper="integrateCsvMapper" />
</pfx:jsonToList>
<integrateMapper id="integrateCsvMapper" includeUnmappedProperties="false">
<simple expression="CZ" out="country"/>
<body in="sku" out="sku"/>
<body in="lastUpdateDate" out="updatedDate"/>
<body in="resultPrice" out="price" converter="stringToDecimal" />
<body in="attribute1" out="manufacturer" />
<body in="label" out="label" />
</integrateMapper>
Â
Example with dynamic header:Â
<bean id="csvDataFormat" class="org.apache.camel.model.dataformat.CsvDataFormat">
<property name="delimiter" value=";"/>
</bean>
<pfx:list-to-csv id="priceListExport" outputUri="file://${data.directory}/pricelists"
injectHeaderFromKeysToFirstLine="true" dataFormat="csvDataFormat"/>
IntegrationManager version 5.8.0