Columns to rows

HI UNIX Gurus,
Not sure if this was already asked and an UNIX Guru has replied but I could not find what i wanted. I have linux environment and need help on this. I have several files like this.

a,1
b,1
utc,10/12/2019
local,10/12/2018
name,xxxy
deg,feh
10,12
20,8
30,50
32,64
46,65
49,66
50,70
51.2,71
54,73.6

and so on

i want the first 5 rows to be in columns repeated like below.

deg,feh,a,b,utc,local,name10,12,1,2,10/12/2019,10/12/2018,xxxy
20,8,1,2,10/12/2019,10/12/2018,xxxy
30,50,1,2,10/12/2019,10/12/2018,xxxy
32,64,1,2,10/12/2019,10/12/2018,xxxy
46,65,1,2,10/12/2019,10/12/2018,xxxy
49,66,1,2,10/12/2019,10/12/2018,xxxy
50,70,1,2,10/12/2019,10/12/2018,xxxy
51.2,71,1,2,10/12/2019,10/12/2018,xxxy
54,73.6,1,2,10/12/2019,10/12/2018,xxxy

Your sample output doesn't match your sample data.
Try

awk -F, '
NR <= 5         {SUF1 = SUF1 DL $1
                 SUF2 = SUF2 DL $2
                 DL = FS
                 next
                }
NR == 6         {printf "%s,%s",   $0, SUF1
                 next
                }
                {printf "%s,%s\n", $0, SUF2
                }
' file

Hello RudiC Sorry somehow it got missed. This is how the output should look like. the values of 1st,2nd,3rd,4th,5th rows repeats for every line. 1,1,10/12,2019,10,12,2018,xxxy .Thank you in advance and I have to do this logic for several files in the same directory

1,1,10/12/2019,10/12/2018,xxxy,a,1 
1,1,10/12/2019,10/12/2018,xxxy,b,1 
1,1,10/12/2019,10/12/2018,xxxy,utc,10/12/2019 
1,1,10/12/2019,10/12/2018,xxxy,local,10/12/2018 
1,1,10/12/2019,10/12/2018,xxxy,name,xxxy 
1,1,10/12/2019,10/12/2018,xxxy,deg,feh 
1,1,10/12/2019,10/12/2018,xxxy,10,12 
1,1,10/12/2019,10/12/2018,xxxy,20,8 
1,1,10/12/2019,10/12/2018,xxxy,30,50 
1,1,10/12/2019,10/12/2018,xxxy,32,64 
1,1,10/12/2019,10/12/2018,xxxy,46,65 
1,1,10/12/2019,10/12/2018,xxxy,49,66 
1,1,10/12/2019,10/12/2018,xxxy,50,70 
1,1,10/12/2019,10/12/2018,xxxy,51.2,71 
1,1,10/12/2019,10/12/2018,xxxy,54,73.6
awk -F, '
NR < 6          {PRFX = PRFX DL $2
                 DL = FS
                 T[NR] = $0
                 next
                }
NR == 6         {for (i=1; i<6; i++) print PRFX, T
                }
                {print PRFX, $0
                }
' OFS=, file

Thank you RudiC why does it throw error what am I missing in this.

[root@sandbox-hdp test]# awk -F, ' NR < 6 {PRFX = PRFX DL $2 DL = FS T[NR] = $0 next } NR == 6 {for (i=1; i<6; i++) print PRFX, T } {print PRFX, $0 } ' OFS=, fil1.csv                                                                 
awk: cmd. line:1:  NR < 6 {PRFX = PRFX DL $2 DL = FS T[NR] = $0 next } NR == 6 {for (i=1; i<6; i++) print PRFX, T } {print PRFX, $0 }                                                                                                  
awk: cmd. line:1:                               ^ syntax error                                                                                                                                                                            
awk: cmd. line:1:  NR < 6 {PRFX = PRFX DL $2 DL = FS T[NR] = $0 next } NR == 6 {for (i=1; i<6; i++) print PRFX, T } {print PRFX, $0 }                                                                                                  
awk: cmd. line:1:                                          ^ syntax error

Don't modify proven scripts without knowing exactly what you are doing. Here: Don't collapse a multiline script into a one liner without the necessary statement terminators, ; . Did you test the unmodified script? To what avail?