Replace null values in csv with zero

Hi,

i have another issue:

i have three files:

FILE 1

ServiceEventHandler,
Processed,Percentage
5285337,100%

FILE 2

Wallet,
Processed,Percentage
5285337,100%

FILE 3

TIME
< 1m
> 1m - 2m
> 2m - 3m
> 3m - 5m
> 5m - 10m
> 10m - 15m
> 15m - 20m
> 20m - 30m
> 30m

i used this code to join all the files

paste -d',' file3 file1 file2 > file4.csv

please see output i get

,ServiceEventHandler,,WalletHandler,
,Processed,Percentage,Processed,Percentage
TIME,2839390,100%,39211657,100%
< 1m,,
> 1m - 2m,,
> 2m - 3m,,
> 3m - 5m,,
> 5m - 10m,,
> 10m - 15m,,
> 15m - 20m,,
> 20m - 30m,,
> 30m,,

My desired output is shown below:

,ServiceEventHandler,,WalletHandler,
TIME,Processed,Percentage,Processed,Percentage
< 1m,2839390,100%,39211657,100%
> 1m - 2m,0,0,0,0
> 2m - 3m,0,0,0,0
> 3m - 5m,0,0,0,0
> 5m - 10m,0,0,0,0
> 10m - 15m,0,0,0,0
> 15m - 20m,0,0,0,0
> 20m - 30m,0,0,0,0
> 30m,0,0,0,0
TOTAL,2839390,100%,39211657,100%

Note: the total should be the sum of fields in Processed and Percentage

Please help. need it badly

Thanks

This is a very rudimentary approach, no bells, no whistles, no error checking, some function(s) might have been defined and used, taking advantage of awk 's default behaviour where possible, but for the samples given it (almost) yields the (what I think is the) desired result (the desired result posted can't possibly have been generated with your sample input!). Try

awk '
NR==1   {getline L1 < F1
         getline L2 < F2
         print "", L1, L2
        }
        {getline L1 < F1
         split (L1, T)
         SUM1 += T[1]
         PRC1 += T[2]
         getline L2 < F2
         split (L2, T)
         SUM2 += T[1]
         PRC2 += T[2]

         print $0, L1, L2
         L1=L2="0,0"
        }

END     {print "TOTAL", SUM1, PRC1 "%", SUM2, PRC2 "%"}
' FS="," OFS="," F1="file1" F2="file2" file3
,ServiceEventHandler,,Wallet,
TIME,Processed,Percentage,Processed,Percentage
< 1m,5285337,100%,5285337,100%
> 1m - 2m,0,0,0,0
> 2m - 3m,0,0,0,0
> 3m - 5m,0,0,0,0
> 5m - 10m,0,0,0,0
> 10m - 15m,0,0,0,0
> 15m - 20m,0,0,0,0
> 20m - 30m,0,0,0,0
> 30m,0,0,0,0
TOTAL,5285337,100%,5285337,100%