pfx-csv Component

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

unmarshal

Split the file into batches first, then unmarshal each batch.

Export Pricefx data to a CSV file

marshal

Fetch data, marshal to CSV, write to file.

Import a very large CSV without loading it all into memory

streamingUnmarshal

Returns a lazy iterator; split after the streaming unmarshal step.

Convert positional CSV data (no header keys needed)

unmarshal

Use useMaps=false to get List<List<String>> instead of maps.

European-locale CSV with semicolons

marshal / unmarshal

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:

XML
<route id="csvImportToDatasource">
    <from uri="file:{{import.fromUri}}"/>
    <split>
        <tokenize group="5000" token="&#10;"/>
        <to uri="pfx-csv:unmarshal?header=sku,label,price&amp;skipHeaderRecord=true&amp;delimiter=,"/>
        <to uri="pfx-api:loaddata?mapper=myMapper&amp;objectType=DM&amp;dsUniqueName=Product"/>
    </split>
    <onCompletion onCompleteOnly="true">
        <to uri="pfx-api:flush?dataFeedName=DMF.Product&amp;dataSourceName=DMDS.Product"/>
    </onCompletion>
</route>

Methods

Method

Direction

Description

marshal

List<Map> → CSV text

Converts a list of maps into a CSV string.

unmarshal

CSV text → List<Map> or List<List>

Parses CSV input into Java collections. Supports Camel split batching.

streamingUnmarshal

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

format

String

Base CSVFormat preset name (DEFAULT, EXCEL, TDF, RFC4180). Optional — omit to use the delimiter/header params directly.

delimiter

String

,

Field delimiter character.

header

String

(auto-detect)

Comma-separated list of column names.

skipHeaderRecord

Boolean

false

Whether to skip the header record.

recordSeparator

String

Platform default

Record separator. Accepts CR, LF, CRLF tokens.

camelSplitIndexAware

Boolean

true

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