Hi
I have 2 csv files which looks like the following and i have to compare the 2 CSVs and create a third file such that if the value of the 1st cell in A.CSV and the value of the first cell in the B.CSV are same, it should print "SAME" in the third file or else print NOT SAME. Likewise i need to create the third file with the SAME/NOT SAME corresponding to each cell in the 2 CSVs.
A.CSV
"1","2009/1/12","DATA",+10.00
"2","2009/1/12","DATA",+11.00
"3","2009/1/12","DATA",+12.00
"4","2009/1/12","DATA",+13.00
B.CSV
"1","2009/1/12","DATA",+99.00
"2","2009/1/12","DATA",+11.00
"3","2009/1/12","DATA",+12.00
"4","2009/1/12","DATA",+13.00
I used the code as below
awk -F',' 'FNR==NR {_[$4]=$0;next}
{ split(_[$4],ar);
for(i=1;i<=NF;i++)
if(ar=$i) $i="SAME,";
else $i="NOT SAME,";
print
}' A.csv B.csv>> C.csv
but it always showed the following output. whether the data was same or not same.
OUTPUT
SAME,SAME,SAME,SAME,
SAME,SAME,SAME,SAME,
SAME,SAME,SAME,SAME,
SAME,SAME,SAME,SAME,
but it is expected to show
SAME,SAME,SAME,NOT SAME,
SAME,SAME,SAME,SAME,
SAME,SAME,SAME,SAME,
SAME,SAME,SAME,SAME,
Thanks in advance for the help.
Regards
Meva
whereas the expected