awk multidimensional values

Hello All,

Here is my input file content and i am trying to write an awk file that produces the output as shown below. i tried with my little knowledge but was not successful.

Input File content:

ID COL1 COL2 COL3
1002 1 val21 val31
1002 2 val22 val32
1002 3 val23 val33
1002 4 val24 val34
1111 1 abc21 abc31
1111 2 abc22 abc32
3124 1 xyz21 pbq31
3124 2 pbq pbq
3124 3 rad brs

Output expected is:
update/1002=(COL1=[1,2,3,4], COL2=[val21,val22,val23,val24], COL3=[val31,val32,val33,val34])
update/1111=(COL1=[1,2], COL2=[abc21,abc22], COL3=[ABC31,ABC32])
update/3124=(COL1=[1,2,3], COL2=[pbq,pbq], COL3=[rad,brs])

I am also attaching my input and output files in case the above content is not clear to read.

I can manage to get the output like this but this is not what i expect
update/1002=(COL1=[1], COL2=[val21], COL3=[val31])
update/1002=(COL1=[2], COL2=[val22], COL3=[val32])

and so on...

Can any one help me please.

Many thanks for your help in advance.

Try...

NR > 1  {
    if (a[$1] == $1) {
        b[$1] = b[$1] "," $2
        c[$1] = c[$1] "," $3
        d[$1] = d[$1] "," $4
    } else {
        a[$1] = $1
        b[$1] = $2
        c[$1] = $3
        d[$1] = $4
    }
}

END {
    for (i in a) {
            printf "update/%s={[%s], COL2=[%s], COL3=[%s])\n", a, b, c, d
    }
}

Many Thanks Ygor.

Will try and let you know the result.