user93796 user93796 - 7 months ago 15
Bash Question

joining two csv files based on a column

I have 2 csv files as follows

AllEmpployees.txt
EmpID,Name

QualifiedEmployeees.csv
Empid


Now i want to find names of qualified employees

Empid,Name


Am using following command

join -t , -1 1 -2 1 QualifiedEmployeees.csv AllEmployees.txt


This results in zero records.Am sure that there is a intersection of employeeids.

Reference : http://superuser.com/questions/26834/how-to-join-two-csv-files

Is it because qualified employees file has only one column and there is no delimiter?Or am i doing something wrong

Answer

Try this:

join -t "," <(dos2unix <QualifiedEmployeees.csv) <(dos2unix <AllEmpployees.txt)