Divide the value of the column if not NULL.

File 1
---------

N_ACCT,CARD_TYPE,CARD_BAL,CUST_CODE
---------------------------------------------------
0301,38,0.00,10
0319,38,54422.92,10
0392,38,0.00,10
0418,38,35254.87,10
0442,38,0.00,10
0491,38,0.00,10
0558,38,45988.76,10
0616,38,0.00,10
0665,38,0.00,10
0699,38,0.00,10

File 2
---------------

N_ACCT,CARD_TYPE,CARD_BAL,CUST_CODE
--------------------------------------------------
0301,38,0.00,10
0319,38,56422.92,10
0392,38,0.00,10
0418,38,38254.87,10
0442,38,0.00,10
0491,38,0.00,10
0558,38,49988.76,10
0616,38,0.00,10
0665,38,0.00,10
0699,38,0.00,10

I have to apply below logic in the script.

If IsNull(File1.CARD_BAL) Then File1.CARD_BAL/2 Else (File 1.CARD_BAL+ File2.CARD_BAL)/2.

Finally output should be in below format
----------------------------------------

N_ACCT,CARD_TYPE,CARD_BAL,CUST_CODE
0301,38,0.00,10
0319,38,54422.92,10

Since I am not familiar with UNIX, appreciate your help on this.

Given your (hypothetical?) IsNull function returns TRUE for Zero values and not, as is done usually in e.g. DB functions, for missing, undefined, or empty variables, the File1.CARD_BAL/2 is pointless, as it will return 0.00 again.
As you seem to want the arithmetic average of file1 and file2 fields, why then is the desired output's second line value 54422.92 , and not 55422.92 ? And, where is the rest of the resulting output lines?
And, how are the files' records related, by line No.? By key (e.g. field 1) value? By what?

awk '
NR < 3
FNR > 2 {line[$1]=$0; sum[$1]+=$3}
END {
   for (i in sum) {
      $0=line;
      $3=sprintf("%0.2f", sum / 2);
      print $0;
   }
}
' FS=, OFS=, file1 file2

While rdrtx1's proposal is based on the assumption that records are related by $1 key value, this one goes for the line No.:

awk '
NR == 1         {for (i=1; i<=NF; i++) if ($i == COL) TGF = i
                }
                {getline TMP < DFN
                 split (TMP, T)
                 if ($TGF+0 > 0) $TGF = ($TGF + T[TGF])/2
                }
1
' FS="," OFS="," COL="CARD_BAL" DFN="file2" file1
N_ACCT,CARD_TYPE,CARD_BAL,CUST_CODE
---------------------------------------------------
0301,38,0.00,10
0319,38,55422.9,10
0392,38,0.00,10
0418,38,36754.9,10
0442,38,0.00,10
0491,38,0.00,10
0558,38,47988.8,10
0616,38,0.00,10
0665,38,0.00,10
0699,38,0.00,10
1 Like