Cygwin / Bash - Join command not working as expected
Posted on 2010-09-10
I have two CSV files I need to combine.
Both of them share a key column (ID), but each file has unique columns otherwise.
Not all of the IDs in the first file have matches in the second file.
I would like the output to include ALL rows from the first file whether they match or not. The rows that did have a match need the additional columns appended.
This seems to be a fairly common question floating around on the internet. The most common solution I found was to use 'join'. However, it isn't behaving as I was expecting.
$ cat test1.csv
$ cat test2.csv
$ join -a 1 -t , test1.csv test2.csv
The output seems to be dropping the "key" value from any rows that match, and I have no idea why the text is overlapping (for example, the Date on output Line 3 is overwriting the name).