If you have duplicates in both files then you need to handle it differently as you need to be clear as to which data from file 2 needs to be picked as there are duplicate keys
ex: file 1
key1 record -01
key1 record -02
key1 record -03
key1 record -04
key1 record -02
key1 record -03
key1 record -04
File 2
key1 aaaaaaaaaa
key1 bbbbbbbbbb
key1 cccccccccc
key1 bbbbbbbbbb
key1 cccccccccc
You see key1 in file 2 has 3 different values , So which value do you need to pick and tag it to File1 ?
key1 record -01 aaaaaaaaaa
key1 record -02 aaaaaaaaaa
key1 record -03 aaaaaaaaaa
key1 record -04 aaaaaaaaaa
key1 record -02 aaaaaaaaaa
key1 record -03 aaaaaaaaaa
key1 record -04 aaaaaaaaaa
or
key1 record -01 bbbbbbbbbb
key1 record -02 bbbbbbbbbb
key1 record -03 bbbbbbbbbb
key1 record -04 bbbbbbbbbb
key1 record -02 bbbbbbbbbb
key1 record -03 bbbbbbbbbb
key1 record -04 bbbbbbbbbb
or
key1 record -01 cccccccccc
key1 record -02 cccccccccc
key1 record -03 cccccccccc
key1 record -04 cccccccccc
key1 record -02 cccccccccc
key1 record -03 cccccccccc
key1 record -04 cccccccccc
or
key1 record -01 aaaaaaaaaa
key1 record -02 bbbbbbbbbb
key1 record -03 cccccccccc
key1 record -04
key1 record -02 bbbbbbbbbb
key1 record -03 cccccccccc
key1 record -04
Tell me the rules and i will show you a way to do it