Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine rows from 2 files and write to DB using Spring Batch

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?

like image 475
user3510366 Avatar asked Feb 21 '26 12:02

user3510366


1 Answers

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

like image 174
Hansjoerg Wingeier Avatar answered Feb 23 '26 05:02

Hansjoerg Wingeier