I have two files file1.csv (20 columns 410k rows) and data.csv (4 columns 1800 rows). What I am trying to do is if data.csv 1st column matches file1.csv 2nd column overwrite 1st column in file1.csv with value from data.csv 3rd column. If no match keep existing value...
this command will list matching lines but could not get the replacement part correctly.
awk -F"," 'BEGIN{OFS=","} {if (NR==FNR) {a[$1]=$3; next} if ($2 in a) print}' data.csv file1.csv
> file3.csv
Thanks!
file1.csv
, ii) an example offile2.csv
and iii) the output you would want from these short examples. That way, we can understand what you need and test our solutions to ensure we give you the output you require.