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