Reputation: 93
I have 2 csv files. I want the information from column 1 of from file 1 to be used to extract rows from the other csv file. My file1.csv has names arranged in columns :
ENSG00000102977
ENSG00000100823
ENSG00000149311
ENSG00000175054
ENSG00000085224
ENSG00000178999
ENSG00000197299
ENSG00000139618
ENSG00000105173
ENSG00000175305
ENSG00000166226
ENSG00000163468
ENSG00000115484
ENSG00000150753
ENSG00000146731
and the 2nd csv file has the names along with the corresponding values arranged in rows.
ENSG00000102977 1083.82334384253 1824.50639384557 1962.86064714976 1367.60568624972
I wrote an awk script
`awk 'FNR == NR{f1[$1];next} $1 in f2 {print $1,$2,$3,$4,$5 $NF}' FS="," file1.csv FS="," file2.csv`
but it returns without any output or error. Kindly guide me as to where I am wrong. Its a bit puzzling since there is no error.
Upvotes: 1
Views: 527
Reputation: 1116
Try grep
's option -f - read pattern from a file.
grep -f fileWithPatterns.csv fileToExtractFrom.csv
Upvotes: 2