open 2 files and compare values script - urgent

Hi gurus

I have two csv files that are outputs. The file contains data similar to

s.no,number1,number2,date1  
--------------------------------
1, a123,482.29,11/28/07 13:00 
2,a124,602.7,9/24/07 14:00
3,a125,266.93,10/9/07 16.48
4,a126,785.15,11/14/07 16:08

<file 2>

s.no name date2 number1 bincode
-------------------------------------
1, el,  9/13/07,  a124,1
2,mg,12/1/06,a125,1
3,wh,3/7/07,a123,0
4,mr,11/24/06,a126,null

The script is to open these two files, compare if date1 is before (earlier) than 10/23/07 and if yes then bincode in file 2 should have 1. If not 1 or incorrectly set to 0 then print it in file3 called report. if date is later then have null or 0 value.

How to do this...

something to start with.
nawk -f inky.awk file1 file2 > file3

inky.awk"

BEGIN {
  FS=OFS=","
  d="071023"
}
function d2d(d,   t) {
   split(d, t, "/")
   return (t[3] t[1] t[2])
}

FNR==NR {
  f1[$1]=d2d(substr($3,1,index($3, " ")-1))
  next
}
$1 in f1 {
   d2=d2d(substr($3,1,index($3, " ")-1))
   if (d2 < d && $NF != 1)
    print
}
1 Like

Hi

I am new to scripting and will appreciate if you can explain the intrecacies of the script. Appreciate.

inky