I am getting a file with data for multiple output tables with different number of columns.
The first column will decide the table where the record should go.
head1|abc|123|sklj|sad
head2|klj|lkj|323|323
tab1|one|two|three|four|five
tab2|one|two|three
tab2|one|two|three
tab3|one|two|three|four
As shown above, head specifies header. So first two lines are header records.
tab1 specifies table 1. which has five columns. So all records starting with tab1 should be loaded in table1.
tab2 specifies table 2. which has three columns. So all records starting with tab2 should be loaded in table2.
tab3 specifies table 3. which has four columns. So all records starting with tab3 should be loaded in table3.
How to achieve this scenario ?
Is there any example available with the same scenario ?
Thanks for reading!
a simple spring batch solution might be:
a more extensible solution might introduce a pre-batch/script which splits the file in 3 (or more) files according to target table and a distinct batch for each type