Code:
$
$ cat -n inputfile
1 1,0,
2 ID,1,
3 a,0,
4 b,0,
5 c,0,
...
...
26 x,0,
27 y,0,
28 z,2;
29 2,0,
30 ID,2,
31 a,0,
...
...
55 y,0,
56 z,0;
57 4,0,
58 ID,3,
59 a,0,
...
...
83 y,0,
84 z,0;
85 3,0,
86 ID,4,
87 a,0,
...
...
111 y,0,
112 z,3;
$
$
$ ##
$ awk -F",|;" '{ if (/^[0-9],/){
> if (NR>1) {
> if (length(s1)>0) {
> print substr(s1,2); s1=""
> }
> print s2
> }
> s2=$1
> } else if($1 != "ID") {
> s2=s2","$2
> }
> if (NR > 1 && NR <= 28) {s1=s1","$1}
> } END {print s2}' inputfile
ID,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3
$
$