how to convert this file using awk

Hi all,
I have a file with this format..

Alphabet,0
1,0,
ID,1,
a,0,
b,0,
c,0,
d,0,
e,0,
f,0,
:
:
:
z,2;
2,0,-->another record
ID,2,
a,0,
b,0,
c,0,
d,0,
e,0,
f,0,
:
:
z,0;
4,0,-->another new record
2,0,
ID,2,
a,0,
b,0,
c,0,
d,0,
e,0,
f,0,
:
:
:
:
:
z,0;
3,0,-->another record
ID,4,
a,0,
b,0,
c,0,
d,0,
e,0,
f,0,
:
:
:
z,3;
:
:
:
The output that I need is:
ID,a,b,c,d,e,f,.....,z
1,0,0,0,0,0,0,.....,2
2,0,0,0,0,0,0,.....,0
4,0,0,0,0,0,0,.....,0
3,0,0,0,0,0,0,.....,3

I have try the code like this
awk '
BEGIN { FS=","}
{if (NR>2 && NR<26)
{printf $2};}
{if (NR>26)
{printf ( "%s,", $2)}}
{if (NR>52)
{printf ( "%s,", $2)}}
{if (NR>78)
{printf ( "%s,", $2)}}' inputfile

output is:
ID,a,b,c,d,e,f,.....,z,1,0,0,0,0,0,0,.....,2,2,0,0,0,0,0,0,.....,0,4,0,0,0,0,0,0,.....,0,3,0,0,0,0,0,0,.....,3-->all become 1 line :frowning:
Which is not what I want. Besides,the number of new record is not consistent. Just have the info that if the $2 end with ";" then, next line is the new records.

ANyone can help?

Thanks

try..

awk '
BEGIN { FS=","} 
{if (NR>2 && NR<26)
{printf $2};}
{if (NR>26)
{printf ( "%s,", $2)}}
{if (NR>52)
{printf ( "%s,", $2)}}
{if (NR>78)
{printf ( "%s,", $2 "\n")}}' inputfile

Hi ryandegreat,

Thanks for your help.

But for this one {if (NR>78)
{printf ( "%s,", $2 "\n")}}

the output become like this
3,
0,
0,
0,
0,
0,
:
:
:
3

Is there any other way that after the awk see the ";", it will know that next line is the new record and print the new record?

Thanks.

Here's another approach in awk:

$ 
$ 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
$ 
$ 

tyler_durden

local $/=";\n";
open FH,"<a.txt";
while(<FH>){
   my @tmp=split("\n",$_);
   print join ",", map {my @t=split(",",$_); $t[1]=~s/[;\n]//; $t[1];} @tmp[1..$#tmp];
   print "\n";
}