Export Data to CSV
This page explains how to fetch data from Pricefx and export it to a CSV file using the Integration Manager.
Basic Example
Fetch all Product Extensions matching a filter and write them to a CSV file:
<filter id="pxCarsFilter">
<and>
<criterion fieldName="name" operator="equals" value="Cars"/>
</and>
</filter>
<route>
<from uri="timer://fetchData?repeatCount=1"/>
<to uri="pfx-api:fetch?filter=pxCarsFilter&objectType=PX"/>
<to uri="pfx-csv:marshal"/>
<to uri="file:test?fileName=data1.csv&fileExist=Append"/>
</route>
pfx-api:fetch Options
The pfx-api:fetch endpoint retrieves data from Pricefx. Below are the most commonly used parameters.
Object Type
The objectType parameter specifies what kind of data to fetch:
|
Value |
Description |
|---|---|
|
P |
Products |
|
PX |
Product Extensions |
|
C |
Customers |
|
CX |
Customer Extensions |
|
DM |
Datamarts |
|
DMDS |
Data Sources |
|
LTV |
Lookup Table Values (Pricing Parameters) |
|
Q |
Quotes |
|
QLI |
Quote Line Items |
Filtering
You can filter data using either a named filter or inline sql:
Named filter:
<to uri="pfx-api:fetch?filter=myFilter&objectType=PX"/>
SQL-like query:
<to uri="pfx-api:fetch?sql=SELECT sku,name,attribute1 WHERE name='Cars'&objectType=PX"/>
Field Selection
-
resultFields— comma-separated field names to include in output (fetches all from DB, returns as Map) -
valueFields— comma-separated field names (fetches only these from DB, returns as list — better performance)
<to uri="pfx-api:fetch?objectType=P&valueFields=sku,name,attribute1"/>
Sorting
Use sortBy to control the order of results (overrides any sortBy defined in the filter):
<to uri="pfx-api:fetch?objectType=PX&filter=myFilter&sortBy=sku"/>
Other Options
|
Parameter |
Default |
Description |
|---|---|---|
|
|
false |
Add DISTINCT clause to results |
|
|
false |
Include null fields in output |
|
|
— |
Manual pagination range |
|
|
— |
For Datamarts/Data Sources (e.g. |
|
|
— |
For Lookup Table Values |
|
|
pricefx |
Named Pricefx connection to use |
Batched Export (Large Datasets)
For large datasets, use batchedMode=true with split to avoid loading all records into memory at once:
<route>
<from uri="timer://fetchData?repeatCount=1"/>
<to uri="pfx-api:fetch?filter=pxCarsFilter&objectType=PX&batchedMode=true&batchSize=5000"/>
<split>
<simple>${body}</simple>
<to uri="pfx-api:fetchIterator"/>
<to uri="pfx-csv:marshal"/>
<to uri="file:export?fileName=data.csv&fileExist=Append"/>
</split>
</route>
|
Parameter |
Default |
Description |
|---|---|---|
|
|
false |
Enable batched fetching |
|
|
5000 |
Number of records per batch |
The first pfx-api:fetch call (with batchedMode=true) returns a list of batch descriptors. The split iterates over them, and pfx-api:fetchIterator fetches each batch using state from the exchange. Always use fetchIterator inside the split — not a second fetch.
pfx-csv:marshal Options
The pfx-csv:marshal endpoint converts fetched data into CSV format.
|
Parameter |
Default |
Description |
|---|---|---|
|
|
|
Field delimiter character |
|
|
— |
Comma-separated header names for output columns |
|
|
false |
Omit the header row from output |
|
|
|
Character used to quote fields |
|
|
— |
Quote mode (e.g. |
|
|
false |
Disable quoting entirely |
|
|
— |
Escape character |
|
|
— |
Line ending: |
|
|
— |
String representation for null values |
|
|
false |
Trim whitespace from values |
|
|
— |
Comments to include before the header |
Example with custom delimiter and headers:
<to uri="pfx-csv:marshal?delimiter=;&header=SKU,ProductName,Price&skipHeaderRecord=false"/>
File Output Options
The standard Camel file: endpoint writes to the local filesystem:
<to uri="file:{{data.directory}}/export?fileName=cars-${date:now:yyyyMMdd-HHmmss}.csv&fileExist=Append"/>
|
Parameter |
Description |
|---|---|
|
|
Output filename (supports Camel expressions like |
|
|
Action if file exists: |
Export to SFTP
To upload the CSV to a remote SFTP server instead of saving locally:
<route>
<from uri="timer://fetchData?repeatCount=1"/>
<to uri="pfx-api:fetch?filter=pxCarsFilter&objectType=PX"/>
<to uri="pfx-csv:marshal"/>
<to uri="sftp:{{ftp.address}}:{{ftp.port}}?username={{ftp.username}}&password={{ftp.password}}&fileName={{ftp.path}}/export_${date:now:yyyyMMdd}.csv&useUserKnownHostsFile=false"/>
</route>
Use {{property}} placeholders instead of hardcoded credentials. Configure them in your application.properties file.
Delta / Incremental Export
To export only records modified since the last run, use a filter with lastUpdateDate:
<filter id="deltaFilter">
<and>
<criterion fieldName="name" operator="equals" value="Cars"/>
<criterion fieldName="lastUpdateDate" operator="greaterThan" value="${header.lastExportTimestamp}"/>
</and>
</filter>
<route id="deltaExport">
<from uri="timer://deltaExport?repeatCount=1"/>
<to uri="pfx-api:fetch?filter=deltaFilter&objectType=PX&batchedMode=true&batchSize=5000"/>
<split>
<simple>${body}</simple>
<to uri="pfx-api:fetchIterator"/>
<to uri="pfx-csv:marshal"/>
<to uri="file:{{data.directory}}/export?fileName=cars-delta-${date:now:yyyyMMdd-HHmmss}.csv"/>
</split>
</route>
Fetching Datamarts and Pricing Parameters
Data Source (DMDS):
<to uri="pfx-api:fetch?objectType=DM&dsUniqueName=1669.DMDS&batchedMode=true&batchSize=5000"/>
Pricing Parameters (Lookup Table Values):
<to uri="pfx-api:fetch?objectType=LTV&pricingParameterName=ExchangeRate&batchedMode=true&batchSize=5000"/>