本文介绍了合并2个文件中的行并使用Spring Batch将其写入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有File1.csv,具有ID,名称,年龄列.File2.csv具有ID列,名称.在这两个文件中,ID均指相同的值,并且是唯一的.样本数据File1.csv

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 dataFile1.csv

id    name    age
101   abc     30
102   def     25

File2.csv

File2.csv

id     designation
101    manager
102    Assistant manager

Spring批处理应同时读取文件,合并数据并按如下所示写入数据库

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

如何在春季批处理中同时读取2个文件?

How to read 2 files simultaneously in spring batch?

推荐答案

您必须实现将两个文件合并在一起的Reader.

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

在这里看看我的答案聚合处理器或聚合阅读器

Have a look at my answer hereAggregating processor or aggregating reader

我已链接到类似问题的其他答案

where I have linked to other answers to a similar question

这篇关于合并2个文件中的行并使用Spring Batch将其写入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:04