Overview
The pfx-csv component is a producer-only Camel component that converts between CSV text and in-memory Java collections. It wraps Apache Commons CSV and adds Pricefx-specific conveniences such as automatic header caching across split batches and BOM-aware encoding.
URI Format
pfx-csv:method?option=value&option=value
Where method is one of marshal, unmarshal, or streamingUnmarshal.
When to Use
|
Scenario |
Method |
Notes |
|---|---|---|
|
Import a CSV file into a Pricefx Data Source |
|
Split the file into batches first, then unmarshal each batch. |
|
Export Pricefx data to a CSV file |
|
Fetch data, marshal to CSV, write to file. |
|
Import a very large CSV without loading it all into memory |
|
Returns a lazy iterator; split after the streaming unmarshal step. |
|
Convert positional CSV data (no header keys needed) |
|
Use useMaps=false to get List<List<String>> instead of maps. |
|
European-locale CSV with semicolons |
|
Set delimiter=; and configure quoteMode as needed. |
Quick Start
Read a CSV file, split into 5000-line batches, unmarshal, and load into a Pricefx Data Source:
<route id="csvImportToDatasource">
<from uri="file:{{import.fromUri}}"/>
<split>
<tokenize group="5000" token=" "/>
<to uri="pfx-csv:unmarshal?header=sku,label,price&skipHeaderRecord=true&delimiter=,"/>
<to uri="pfx-api:loaddata?mapper=myMapper&objectType=DM&dsUniqueName=Product"/>
</split>
<onCompletion onCompleteOnly="true">
<to uri="pfx-api:flush?dataFeedName=DMF.Product&dataSourceName=DMDS.Product"/>
</onCompletion>
</route>
Methods
|
Method |
Direction |
Description |
|---|---|---|
|
|
List<Map> → CSV text |
Converts a list of maps into a CSV string. |
|
|
CSV text → List<Map> or List<List> |
Parses CSV input into Java collections. Supports Camel split batching. |
|
|
CSV text → CSVParser (iterator) |
Returns a lazy iterator over CSV records for large files. Cannot be used inside a <split>. |
Shared Parameters
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
String |
— |
Base CSVFormat preset name ( |
|
|
String |
|
Field delimiter character. |
|
|
String |
(auto-detect) |
Comma-separated list of column names. |
|
|
Boolean |
|
Whether to skip the header record. |
|
|
String |
Platform default |
Record separator. Accepts |
|
|
Boolean |
|
Uses Camel SPLIT_INDEX for split-batch header caching. |
See subpages for the full parameter list per method.
See Also
-
pfx-csv:marshal — Marshal details, parameters, and examples
-
pfx-csv:unmarshal — Unmarshal details, parameters, and examples
-
pfx-csv:streamingUnmarshal — Streaming unmarshal details and limitations
-
pfx-excel Component — For Excel file handling