Summing up rows data regarding 1st column

Dear all,

I have one file like

   
  LABEL   A   B   C   D   E   F   G   H   I   J   K   L   M   N      
 G02100   64651.3   25630.7   8225.21   51238   267324   268005   234001   52410.9   18598.2   10611   10754.7   122535   267170   36631.4     
  G02100   12030.3   8260.15   8569.91   7901.76   6730.83   3060.29   4991.3   10213.1   5043.9   4889.69   3838.4   3652.25   3742.68   5945   
    G02100   10909.1   222.446   0   0   0   0   0   295.779   19.884   0   0   0   0   0      
 G02780   8287.85   8067.36   5764.61   7754.75   4428.79   1653.26   4524.88   6942.11   6309.85   6228.8   8280.75   3437.41   3310.83   4884.93     
  G02780   7780.28   19497.7   10218.1   10975.8   3154.82   191.512   64.78   5298.8   16604.7   12996.6   3010.33   751.934   143.949   9.5502       
G09200   6974.73   7790.54   3865.08   7108.96   3778.3   1625.9   4294.91   4277.2   4259.59   4709.11   7341.28   3574.67   3382.8   4967.7      
 G37770   6924.22   6072.77   1353.14   708.795   140.226   125.069   437.265   5715.5   2883.18   2494.85   5448.92   698.224   503.822   100.277   
    G74270   10681.8   11908.3   3564.38   10432.4   4826.1   2020.65   7799.51   8969.07   5302.4   4989.71   22158   7662.56   6693.63   4412.19   
    G74270   10060.6   6502.83   297.032   115.507   397.306   261.864   1399.25   3488.46   2995.85   1472.46   2026.57   537.095   935.669   606.438    
   G74270   9492.4   4574.97   506.054   288.768   327.193   527.636   861.574   6589.79   2372.82   1589.15   1395.78   769.837   1151.59   615.988      
 G74270   9318.15   20012.7   10330.1   267.767   0   0   0   12057.4   11963.5   17414   0   0   0   0       
G74270   9265.12   11326.2   1430.15   0   0   33.2215   53.4435   4762.92   9749.78   7251.19   0   17.9032   215.924   630.313  
     G35720   7575.73   11826.7   8415.9   6011.63   1834.62   582.353   1230.82   7020.41   13918.8   13757.8   1207.89   1432.25   359.873   816.542   

i need to have an output file (summing up the values in rows according to the first column) like

       
  LABEL   A   B   C   D   E   F   G   H   I   J   K   L   M   N     
  G02100   87590.7   34113.3   16795.12   59139.76   274054.8   271065.3   238992.3   62919.78   23661.98   15500.69   14593.1   126187.3   270912.7   42576.4    
   G02780   16068.13   27565.06   15982.71   18730.55   7583.61   1844.772   4589.66   12240.91   22914.55   19225.4   11291.08   4189.344   3454.779   4894.48    
   G09200   6974.73   7790.54   3865.08   7108.96   3778.3   1625.9   4294.91   4277.2   4259.59   4709.11   7341.28   3574.67   3382.8   4967.7      
 G74270   48818.07   54325   16127.72   11104.44   5550.599   2843.372   10113.78   35867.64   32384.35   32716.51   25580.35   8987.395   8996.813   6264.929     
  G35720   7575.73   11826.7   8415.9   6011.63   1834.62   582.353   1230.82   7020.41   13918.8   13757.8   1207.89   1432.25   359.873   816.542   

Please help me guys

Thanks

Hi, try this:

awk 'NR==1{n=NF;print;next} {A[$1];for(i=2;i<=n;i++) S[$1,i]+=$i} END{for(label in A){p=label; for (i=2;i<=n;i++) p=p FS S[label,i]; print p}}' infile

Thanks Scrutinizer,
it did the summing up but problem is, all the summing results are in the columns (Label; A; B; C ;D;E;F;G;H;I;J;K;L;M;N) its only in first column with all the readings.
its a tab delimited file with 15 columns and >20, 000 rows.
So ? :confused:

regards

Could you elaborate, I don't know what you mean. Do you mean output should be TAB-separated? :

awk 'NR==1{n=NF;$1=$1;print;next} {A[$1];for(i=2;i<=n;i++) S[$1,i]+=$i} END{for(label in A){p=label; for (i=2;i<=n;i++) p=p OFS S[label,i]; print p}}' OFS='\t' infile
LABEL	A	B	C	D	E	F	G	H	I	J	K	L	M	N
G09200	6974.73	7790.54	3865.08	7108.96	3778.3	1625.9	4294.91	4277.2	4259.59	4709.11	7341.28	3574.67	3382.8	4967.7
G02100	87590.7	34113.3	16795.1	59139.8	274055	271065	238992	62919.8	23662	15500.7	14593.1	126187	270913	42576.4
G37770	6924.22	6072.77	1353.14	708.795	140.226	125.069	437.265	5715.5	2883.18	2494.85	5448.92	698.224	503.822	100.277
G74270	48818.1	54325	16127.7	11104.4	5550.6	2843.37	10113.8	35867.6	32384.3	32716.5	25580.3	8987.4	8996.81	6264.93
G35720	7575.73	11826.7	8415.9	6011.63	1834.62	582.353	1230.82	7020.41	13918.8	13757.8	1207.89	1432.25	359.873	816.542
G02780	16068.1	27565.1	15982.7	18730.5	7583.61	1844.77	4589.66	12240.9	22914.6	19225.4	11291.1	4189.34	3454.78	4894.48

:b: yes exactly this i need,

Thanks a lot

Regards