2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by javausers
0

Not enough info. Merge by concatenation, by joining records in input order, by joining based on a key value present in both files? Etc?
Formats or examples of both files, and how are they to be merged (or an example output file) would be really helpful here.

0

I'm sorry for that.
Here are the example files,
1st file looks like:
sno,first name,last name
1,xx,yy
2,aa,bb

2nd file looks like:
sno,place
1,pp
2,qq

Output:
sno,first name,last name,place
1,xx,yy,pp
2,aa,bb,qq

0

Read each file into a map (2 files, 2 maps) by extracting the sno to use as key, and put the rest of the line as the value.
When you have the two maps look through all the keys in the first map, and get the corresponding values from both maps. For each key concatenate the key with both values and write that to the output file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.