04-10-2012
Summing up rows data regarding 1st column
Dear all,
I have one file like
Code :
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
Code :
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
Last edited by AAWT; 04-10-2012 at 08:07 AM ..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I want to find the different column numbers among rows in a file. For example:
A001 a b c d e ... N
A002 a b c d e ... N
A003 a b c d e ... N+1
A004 a b c d e ... N
A005 a b c d e ... N+2
:
:
For most of the lines I will have N columns (say 1000 rows) in each line except the line 3... (5 Replies)
Discussion started by: AMBER
5 Replies
2. Shell Programming and Scripting
Hi every one,
I am trying to organise an input text file like:
input
1 2 3 4 5
6 7 8
9 10
11 12 13 14 15
16 17 18
19 20
into an output as following:
output file
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20 (5 Replies)
Discussion started by: nxp
5 Replies
3. Shell Programming and Scripting
I can no longer find my commands, but I use to be able to transpose data with common fields from a single column to rows using a command line. My data is separated as follows:
NAME=BOB
ADDRESS=COLORADO
PET=CAT
NAME=SUSAN
ADDRESS=TEXAS
PET=BIRD
NAME=TOM
ADDRESS=UTAH
PET=DOG
I would... (7 Replies)
Discussion started by: docdave78
7 Replies
4. Shell Programming and Scripting
Hi..
In the below sorted input file.. I am comparing the first 3 columns of data one by one row and it is a pipeline delimitter file..
AA|BB|CC|line1
AA|BB|CC|ine4
AA|BB|CC|line2
BB|CC|DD|line3
BB|CC|DD|line5
If first 3 columns of data matches with any record in the file the... (4 Replies)
Discussion started by: NareshN
4 Replies
5. Shell Programming and Scripting
input:
chr1 1 2 3
chr1 1 2 4
chr1 2 4 5
chr2 3 6 9
chr2 3 6 10
Code:
awk '{a+=$4}END{for (i in a) print i,a}' input
Output:
chr112 7
chr236 19
chr124 5
Desired output:
chr1 1 2 7
chr2 3 6 19
chr1 2 4 5 (1 Reply)
Discussion started by: jacobs.smith
1 Replies
6. Shell Programming and Scripting
data file contains
failed=24
error=23
error=163
failed=36
error=903
i need to get a total count of each value above. i'm looking for the most efficient method to do this as the datafile i provided is just a sample. the actual data can be several hundred thousands of lines.
so from... (3 Replies)
Discussion started by: SkySmart
3 Replies
7. Shell Programming and Scripting
Hi all ,
I have a file with the below content
Header Section
employee|employee name||Job description|Job code|Unitcode|Account|geography|C1|C2|C3|C4|C5|C6|C7|C8|C9|Csource|Oct|Nov|Dec|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep
Data section ... (1 Reply)
Discussion started by: Hypesslearner
1 Replies
8. Shell Programming and Scripting
Hello Everyone,
I have a input file looks like
-0.005-0.004-0.003-0.002-0.00100.0010.0020.0030.0040.005My desired output should look like
-0.005
-0.004
-0.003
-0.002
-0.001
0
0.001
0.002
0.003
0.004
0.005I had some success in getting the desired output. But i face a problem when i... (15 Replies)
Discussion started by: dinesh.n
15 Replies
9. Shell Programming and Scripting
I have data such as below where the value in second field is the same as that in the row after.
123456,22222,John,0,xyz
234567,22222,John1,1,cde
43212,3333,Jean,3,pip
84324,3333,Abel,2,cat
I'd like to rearrange the output like below to put such records beside each other and separated with... (5 Replies)
Discussion started by: james2009
5 Replies
10. UNIX for Beginners Questions & Answers
Hello Everyone,
I am very new to the world of regular expressions. I am trying to use grep/sed for the following:
Input file is something like this and there are multiple such files:
abc
1
2
3
4
5
***END***
abc
6
7
8
9
***END***
abc
10 (2 Replies)
Discussion started by: shellnewuser
2 Replies
LEARN ABOUT SUNOS
iconv_8859-2
iconv_8859-2(5) Standards, Environments, and Macros iconv_8859-2(5)
NAME
iconv_8859-2 - code set conversion tables for ISO 8859-2 (Latin 2)
DESCRIPTION
The following code set conversions are supported:
+--------------------------------------------------------------------+
| Code Set Conversions Supported |
+--------------+--------+--------------+--------+--------------------+
| Code |Symbol |Target Code |Symbol | Target Output |
+--------------+--------+--------------+--------+--------------------+
|ISO 8859-2 |iso2 |MS 1250 |win2 | Windows Latin 2 |
+--------------+--------+--------------+--------+--------------------+
|ISO 8859-2 |iso2 |MS 852 |dos2 | MS-DOS Latin 2 |
+--------------+--------+--------------+--------+--------------------+
|ISO 8859-2 |iso2 |Mazovia |maz | Mazovia |
+--------------+--------+--------------+--------+--------------------+
|ISO 8859-2 |iso2 |DHN |dhn | Dom Handlowy Nauki |
+--------------+--------+--------------+--------+--------------------+
CONVERSIONS
The conversions are performed according to the following tables. All values in the tables are given in octal.
ISO 8859-2 to MS 1250
For the conversion of ISO 8859-2 to MS 1250, all characters not in the following table are mapped unchanged.
+-----------------------------------------------------------------+
| | Conversions|Performed | |
| ISO 8859-2 | MS 1250 | ISO 8859-2 | MS 1250 |
|24 | 4 |261 |271 |
|177-237 | 40 |265 |276 |
|241 | 245 |266 |234 |
|245 | 274 |267 |241 |
|246 | 214 |271 |232 |
|251 | 212 |273 |235 |
|253 | 215 |274 |237 |
|254 | 217 |276 |236 |
|256 | 216 |266 |236 |
+---------------+----------------+----------------+---------------+
ISO 8859-2 to MS 852
For the conversion of ISO 8859-2 to MS 852, all characters not in the following table are mapped unchanged.
+-----------------------------------------------------------------+
| | Conversions|Performed | |
| ISO 8859-2 | MS 852 | ISO 8859-2 | MS 852 |
|24 | 4 |316 |327 |
|177-237 | 40 |317 |322 |
|240 | 377 |320 |321 |
|241 | 244 |321 |343 |
|242 | 364 |322 |325 |
|243 | 235 |323 |340 |
|244 | 317 |324 |342 |
|245 | 225 |325 |212 |
|246 | 227 |326 |231 |
|247 | 365 |327 |236 |
|250 | 371 |330 |374 |
|251 | 346 |331 |336 |
|252 | 270 |332 |351 |
|253 | 233 |333 |353 |
|254 | 215 |334 |232 |
|255 | 360 |335 |355 |
|256 | 246 |336 |335 |
|257 | 275 |337 |341 |
|260 | 370 |340 |352 |
|261 | 245 |341 |240 |
|262 | 362 |342 |203 |
|263 | 210 |343 |307 |
|264 | 357 |344 |204 |
|265 | 226 |345 |222 |
|266 | 230 |346 |206 |
|267 | 363 |347 |207 |
|270 | 367 |350 |237 |
|271 | 347 |351 |202 |
|272 | 255 |352 |251 |
|273 | 234 |353 |211 |
|274 | 253 |354 |330 |
|275 | 361 |355 |241 |
|276 | 247 |356 |214 |
|277 | 276 |357 |324 |
|300 | 350 |360 |320 |
|301 | 265 |361 |344 |
|302 | 266 |362 |345 |
|303 | 306 |363 |242 |
|304 | 216 |364 |223 |
|305 | 221 |365 |213 |
|306 | 217 |366 |224 |
|307 | 200 |367 |366 |
|310 | 254 |370 |375 |
|311 | 220 |371 |205 |
|312 | 250 |372 |243 |
|313 | 323 |374 |201 |
|314 | 267 |375 |354 |
|315 | 326 |376 |356 |
|366 | 367 | | |
+---------------+----------------+----------------+---------------+
ISO 8859-2 to Mazovia
For the conversion of ISO 8859-2 to Mazovia, all characters not in the following table are mapped unchanged.
+-----------------------------------------------------------------+
| | Conversions|Performed | |
| ISO 8859-2 | Mazovia | ISO 8859-2 | Mazovia |
|24 | 4 |323 |243 |
|177-237 | 40 |324-325 |40 |
|240 | 377 |326 |231 |
|241 | 217 |327-333 |40 |
|242 | 40 |334 |232 |
|243 | 234 |335-336 |40 |
|244-245 | 40 |337 |341 |
|246 | 230 |340-341 |40 |
|247-253 | 40 |342 |203 |
|254 | 240 |343 |40 |
|255-256 | 40 |344 |204 |
|257 | 241 |345 |40 |
|260 | 370 |346 |215 |
|261 | 206 |347 |207 |
|262 | 40 |350 |40 |
|263 | 222 |351 |202 |
|264-265 | 40 |352 |221 |
|266 | 236 |353 |211 |
|267-273 | 40 |354-355 |40 |
|274 | 246 |356 |214 |
|275-276 | 40 |357-360 |40 |
|277 | 247 |361 |244 |
|300-303 | 40 |362 |40 |
|304 | 216 |363 |242 |
|305 | 40 |364 |223 |
|306 | 225 |365 |40 |
|307 | 200 |366 |224 |
|310-311 | 40 |367 |366 |
|312 | 220 |370-373 |40 |
|313-320 | 40 |374 |201 |
|321 | 245 |375-376 |40 |
|322 | 40 | | |
+---------------+----------------+----------------+---------------+
ISO 8859-2 to DHN
For the conversion of ISO 8859-2 to DHN, all characters not in the following table are mapped unchanged.
+-----------------------------------------------------------------+
| | Conversions|Performed | |
| ISO 8859-2 | DHN | ISO 8859-2 | DHN |
|24 | 4 |322 |40 |
|177-237 | 40 |323 |205 |
|240 | 377 |324-325 |40 |
|241 | 200 |326 |231 |
|242 | 40 |327-333 |40 |
|243 | 203 |334 |232 |
|244-245 | 40 |335-336 |40 |
|246 | 206 |337 |341 |
|247-253 | 40 |340 |40 |
|254 | 207 |341 |240 |
|255-256 | 40 |342-345 |40 |
|257 | 210 |346 |212 |
|260 | 370 |347-351 |40 |
|261 | 211 |352 |213 |
|262 | 40 |353-354 |40 |
|263 | 214 |355 |241 |
|264-265 | 40 |356-360 |40 |
|266 | 217 |361 |215 |
|267-273 | 40 |362 |40 |
|274 | 220 |363 |216 |
|275-276 | 40 |364 |223 |
|277 | 221 |365 |40 |
|300-305 | 40 |366 |224 |
|306 | 201 |367 |366 |
|307-311 | 40 |370-371 |40 |
|312 | 202 |372 |243 |
|313-320 | 40 |373-376 |40 |
|321 | 204 | | |
+---------------+----------------+----------------+---------------+
FILES
/usr/lib/iconv/*.so conversion modules
/usr/lib/iconv/*.t conversion tables
/usr/lib/iconv/iconv_data list of conversions supported by conversion tables
SEE ALSO
iconv(1) , iconv(3C) , iconv(5)
SunOS 5.10 18 Apr 1997 iconv_8859-2(5)