I am experiencing problems trying to join the following two files using GNU join v8.22:
FILE1.TXT
KEY;COLUMN1;COLUMN2;COLUMN3;COLUMN4
A02046464;9.1.3;1.1.3;;A02054062
A02047835;9.1.3;1.2;;A12345678
A02047843;9.1.3;1.1.2;20121016;
A02048288;9.2.8.2.7;4.2.3.7;;
FILE2.TXT
KEY;COLUMN1;COLUMN2
A02046464;;
A02047835;;
A02047843;9.1.3;1.1.2
A02048288;9.2.8.2.7;4.2.3.7
Using the following command
LC_ALL=C join -j 1 -a 1 -a 2 -t ';' --header FILE1.TXT FILE2.TXT
But the output seems to be broken, as if the columns from FILE2.TXT were overwritting those from FILE1.TXT.
;COLUMN1;COLUMN2MN2;COLUMN3;COLUMN4
;;2046464;9.1.3;1.1.3;;A02054062
;;2047835;9.1.3;1.2;;A12345678
;9.1.3;1.1.21.3;1.1.2;20121016;
;9.2.8.2.7;4.2.3.77;4.2.3.7;;
Notice that the header and data seem to be overwritten by the 2 columns of FILE2. Also, the key column isn't shown at the output.
If I try to run the command using the -o FORMAT option explicitly (LC_ALL=C join -j 1 -a 1 -a 2 -t ';' --header -o 0,1.2,1.3,1.4,1.5,2.2,2.3 FILE1.TXT FILE2.TXT
), the output is the same.
Interestingly, this only happens when I add fields from FILE2.TXT to the output. If I only show those from FILE1.TXT, it seems to work:
LC_ALL=C join -j 1 -a 1 -a 2 -t ';' --header -o 0,1.2,1.3,1.4,1.5 FILE1.TXT FILE2.TXT
KEY;COLUMN1;COLUMN2;COLUMN3;COLUMN4
A02046464;9.1.3;1.1.3;;A02054062
A02047835;9.1.3;1.2;;A12345678
A02047843;9.1.3;1.1.2;20121016;
A02048288;9.2.8.2.7;4.2.3.7;;
But as soon as I add one field from FILE2.TXT, the key column disappears and this new column overwrite those from FILE1.TXT:
LC_ALL=C join -j 1 -a 1 -a 2 -t ';' --header -o 0,1.2,1.3,1.4,1.5,2.2 FILE1.TXT FILE2.TXT
;COLUMN1MN1;COLUMN2;COLUMN3;COLUMN4
;02046464;9.1.3;1.1.3;;A02054062
;02047835;9.1.3;1.2;;A12345678
;9.1.3843;9.1.3;1.1.2;20121016;
;9.2.8.2.79.2.8.2.7;4.2.3.7;;
Could someone provide me some help? Thanks!