3

I have File1.csv, with the columns id,name,age. File2.csv has the columns id,designation. In both the files ID refers to same value and is unique. Sample data File1.csv

id    name    age
101   abc     30
102   def     25

File2.csv

id     designation
101    manager
102    Assistant manager

Spring batch should read the files simultaneously, combine the data and write to DB as below

id   name    age   designation
101  abc     30     manager
102  def     25     Assistant manager

How to read 2 files simultaneously in spring batch?

1 Answer 1

1

You have to implement a Reader that merges the two files togehter.

Have a look at my answer here Aggregating processor or aggregating reader

where I have linked to other answers to a similar question

Sign up to request clarification or add additional context in comments.

2 Comments

Will this work for 2 files with different columns and are not in sorted order?
No, that is not possible. You need to have an identifier column, which links the two elements together. And, because of the sequentiel reading, all sources must be ordered based in this id column. This also ensures the best possible performance that is attainable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.