Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

Using grep to "vlookup" values from one csv to another

$
0
0

I have 2 csv files -

file1.csv with a list of 5 IDs in col A (col 1)

file2.csv that has a table with multiple hundred rows and cols. One of the cols (col 8) matches the IDs in file1.csv

I want to use this matching col to print a few other cols from file2.csv for the list in file1.csv

This is what I have tried so far and didnt work -

Try 1 - awk 'NR==FNR{a[$1];next}$8 in a{print $8,$10,$51,$67}''File1.csv''File2.csv'

This probably didnt work because a few of the rows have commas in the data in the cols preceding col 8 in file2.csv

Try 2 - grep -F 'File1''File2.csv'

Not sure why this didnt work


Viewing all articles
Browse latest Browse all 102

Trending Articles