Skip to main content

Import transactions with format reader

This sample shows how to import transactions in custom CSV format to FA using reader format configuration and a Camel route. The highlights of this sample are:

  1. Creating a reader format configuration to convert the custom file format to FA transaction import format.

  2. Setting up a camel route and feeding the file to the reader format configuration and further to the transaction import process.

Starting point

You have a semicolon-separated file that looks like this:

Transaction type;Status;Transaction date;Amount;Price;Trade amount;Parent portfolio
Buy;Active;2022-02-08;10;100;1000;Clark Kent 

Create the reader format configuration

Go to Preference > Importing > Reader format configuration in FA Back, fill in the fields in the Basic info tab and click next. You can find instructions about the Reader format configuration in the FA Back reference: Preference - Importing.

In this sample, you need to set the field order in the right column according to this:


Set up the Camel route

Upload the Camel route in FA back. For the instructions, see Deploy Camel routes

The route below:

  • Reacts to all files with the name that ends with Transactions.csv (antInclude=*Transactions.csv) placed in the /integrations/customFiles/ directory.

  • Archives the original file in the monthly folders after processing (move=./history/${date:now:MM_yyyy}/${file:onlyname})

  • Feeds the processed file for transaction import mapping directory and adds the mapping name to the processed file name extension (custom_transactions.custom-reader.csv). The route knows which reader format configuration to apply by matching the import reader configuration name and the file name, in this case they are custom-reader.

<routes xmlns="">
    <route id="customTransactionImportMapping">
        <from uri="file:{{back.writable.dir}}/integrations/customFiles/?antInclude=*Transactions.csv&amp;autoCreate=true&amp;charset=iso-8859-1&amp;readLock=changed&amp;readLockCheckInterval=5000&amp;moveFailed=.failed&amp;move=./history/${date:now:MM_yyyy}/${file:onlyname}"/>        
        <to uri="file:{{back.writable.dir}}/fa/import/general/csv-auto/mapped-transactions?autoCreate=true&amp;fileName=${file:onlyname.noext}.custom-reader.${file:ext}&amp;charset=iso-8859-1"/>