I need to compare two files, File1.csv and File2.csv (Separated by ',') using Awk
Logic:
Column PID in both files are reference.
If for same 'PID' in 'File1.csv' and 'File2.csv' and in both files column 'Value' value is same then 'File2.csv' column 'UTS' value update for this column getting value from 'File1.csv' column 'RTS'.
Else for same 'PID' in 'File1.csv' and 'File2.csv' and in both files column 'Value' value is not same then 'File2.csv' column 'Value,RTS,UTS' value update for this column getting value from 'File1.csv' column 'Value,RTS,UTS'
File1.csv:
PID,Value,RTS
1,50,10:30:00
2,22,10:15:00
3,34,10:18:00
4,54,10:20:00
5,54,10:22:00
6,54,10:25:00
7,80,10:50:00
8,60,10:32:00
9,45,10:35:00
File2.csv:
PID,Value,RTS,UTS
1,12,10:10:00,10:14:00
2,22,10:15:00,10:17:00
3,34,10:18:00,10:19:00
4,54,10:20:00,10:21:00
5,54,10:22:00,10:24:00
6,54,10:25:00,10:29:00
7,60,10:30:00,10:31:00
8,60,10:32:00,10:34:00
9,45,10:35:00,10:35:00
Output:
PID,Value,RTS,UTS
1,50,10:30:00,10:30:00
2,22,10:15:00,10:15:00
3,34,10:18:00,10:18:00
4,54,10:20:00,10:20:00
5,54,10:22:00,10:22:00
6,54,10:25:00,10:25:00
7,80,10:50:00,10:50:00
8,60,10:32:00,10:32:00
9,45,10:35:00,10:35:00
Best Answer
Try this: