04-23-2010
I have no problem getting the output based on Scrutinizer suggestion:
awk -F, '{A[$3","$4]+=$2} END{for (i in A) print A[i]","i}' input
22,beta,5
16,gamma,3
11,alpha,4
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
I have the following input which i want to process using AWK.
Rows,NC,amount
1,1202,0.192387
2,1201,0.111111
3,1201,0.123456
i want the following output
count of rows = 3 ,sum of amount = 0.426954
Many thanks (2 Replies)
Discussion started by: pistachio
2 Replies
2. Shell Programming and Scripting
Dear All,
I have a data file input.csv like below. (Only five column shown here for example.)
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
3,2,4,5,6
5,3,5,5,6
From this I want the below output
Data1,StepNo,Data2,Data3,Data4
2,1,3,4,5
3,1,5,6,7
where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies
3. Shell Programming and Scripting
I have a following inputfile
MT,AP,CDM,TTML,MUM,GS,SUCC,3
MT,AP,CDM,TTSL,AP,GS,FAIL,9
MT,AP,CDM,RCom,MAH,GS,SUCC,3
MT,AP,CDM,RTL,HP,GS,SUCC,1
MT,AP,CDM,Uni,UPE,GS,SUCC,2
MT,AP,CDM,Uni,MUM,GS,SUCC,2
TTSL,AP,GS,MT,MAH,CDM,SUCC,20
TTML,AP,GS,MT,MAH,CDM,FAIL,10... (2 Replies)
Discussion started by: siramitsharma
2 Replies
4. Shell Programming and Scripting
Dear fellows, I need your help.
I'm trying to write a script to convert a single column into multiple rows.
But it need to recognize the beginning of the string and set it to its specific Column number.
Each Line (loop) begins with digit (RANGE).
At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies
5. Shell Programming and Scripting
Hi,
I have a similar input format-
A_1 2
B_0 4
A_1 1
B_2 5
A_4 1
and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks!
letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies
6. Shell Programming and Scripting
Hi,
I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column)
The input is for example, after sorted:
K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies
7. UNIX for Dummies Questions & Answers
Hi All,
I have a requirement where I need to find sum of values from column D through O present in a CSV file and check whether the sum of each Individual column matches with the value present for that corresponding column present in the trailer record.
For example, let's assume for column D... (9 Replies)
Discussion started by: tpk
9 Replies
8. UNIX for Beginners Questions & Answers
I have a file which need to be summed up using date column.
I/P:
2017/01/01 a 10
2017/01/01 b 20
2017/01/01 c 40
2017/01/01 a 60
2017/01/01 b 50
2017/01/01 c 40
2017/01/01 a 20
2017/01/01 b 30
2017/01/01 c 40
2017/02/01 a 10
2017/02/01 b 20
2017/02/01 c 30
2017/02/01 a 10... (6 Replies)
Discussion started by: Booo
6 Replies
9. Shell Programming and Scripting
Hi Experts,
Please bear with me, i need help
I am learning AWk and stuck up in one issue.
First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique.
Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies
10. Shell Programming and Scripting
Hello,
I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically
I/p
c1,c2,c3,c4,c5
10,20,30,40,50
20,30,40,50,60
If i want to find sum only column c1, c3 and output it as c6,c7
O/p
c1,c2,c3,c4,c5,c6,c7
10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies
LEARN ABOUT OPENSOLARIS
pngtopnm
pngtopnm(1) General Commands Manual pngtopnm(1)
NAME
pngtopnm - convert a Portable Network Graphics file into portable anymap
SYNOPSIS
pngtopnm [-verbose] [-alpha | -mix] [-background color]
[-gamma value] [-text file] [-time] [pngfile]
DESCRIPTION
Reads a Portable Network Graphics as input. Produces a portable anymap as output. The type of the output file depends on the input file -
if it's black & white, a pbm file is written, else if it's grayscale a pgm file, else a ppm file.
OPTIONS
-verbose
Display the format of the input file and the type of the output file. If the chunks are part of the png-file, the alpha, trans-
parency and gamma-values will be indicated.
-alpha Output the alpha channel or transparency mask of the image. The result is either a pbm file or pgm file, depending on whether dif-
ferent levels of transparency appear.
-mix Compose the image with the transparency or alpha mask against a the background. When a background chunk is available that color is
taken, else black will do.
-background color
If no background color chunck is present in the png-file, or when another color is required this parameter can be used to set the
background color of images. This is especially useful for alpha-channel images or those with transparency chunks. The format, to
specify the color in, is either (in the case of orange) "1.0,0.5,0.0", where the values are floats between zero and one, or with the
syntax "#RGB", "#RRGGBB" or "#RRRRGGGGBBBB" where R, G and B are hexa-decimal numbers.
-gamma value
Converts the image to a new display-gamma value. When a gAMA chunk is present in the png-file, the image-gamma value will be used.
When not, the image-gamma is considered to be 1.0. Based on the image-gamma and the display-gamma given with this option the colors
written to the pnm-file will be adjusted.
Because the gamma's of uncompensated monitors are around 2.6, which results in an image-gamma of 0.45, some typical situations are:
when the image-gamma is 0.45 (use -verbose to check) and the picture is too light, your system is gamma-corrected, so convert with
"-gamma 1.0". When no gAMA chunk is present or the image-gamma is 1.0, use 2.2 to make the picture lighter and 0.45 to make the
picture darker.
-text file
Writes the tEXt and zTXt chunks to a file, in a format as described in the pnmtopng man-page. These chunks contain text comments or
annotations.
-time Prints the tIME chunk to stderr.
All flags can be abbreviated to their shortest unique prefix.
SEE ALSO
pnmtopng(1), ptot(1), pnmgamma(1), pnm(5)
NOTE
Instead of pngtopnm|pnmtoxxx, a specific converter should be used, if available. E.g. ptot (PNG to TIFF conversion), etc.
BUGS
There could be an option to read the comment text from pnm comments instead of a separate file.
The program could be much faster, with a bit of code optimizing.
AUTHORS
Copyright (C) 1995-1997 by Alexander Lehmann
and Willem van Schaik.
6 January 1997 pngtopnm(1)