I'm fairly new to Apache Camel.
I've been writing routes that process a csv file using the BindyCsvformat
class. So far, the CSV files I'm processing are fairly straight-forward, in the sense that they have a fixed number of records.
So using the @DataField
annotation to define positions of the columns is not a problem.
However I've come across a CSV file, where number of columns are dynamic. This CSV file only contains 1 row.
The column numbers are dynamic based on the value of a column called 'number of periods'.
If the value in the 'number of periods' column is '5', then there are 5 extra columns added to the file.
Here is an example of the headings in this particular CSV file:
sample-csv.txt
row_id, number_of_periods, result_period, result_period, result_period
0,3,0.00,10.00,10.00.
As you can see from the sample data above, because the 'number_of_periods' column shows '3', there are three 'result_period' columns. If the 'number_of_periods' field was 5, then there would be 5 'result_period' columns.
Can anyone assist (or point me to any references) where BindyCsvFormat
(via Camel) can handle this dynamic column mapping? Unless I'm mistaken, I think the @DataField
annotation can only be applied to fixed fields (assuming the total number of columns is known before hand.
Thanks in advance.