Sponsored Content
Top Forums Shell Programming and Scripting Sum Of Column Based On Column Condition Post 302797397 by hanson44 on Monday 22nd of April 2013 01:30:01 PM
Old 04-22-2013
Quote:
to be clubbed
I hope not. Smilie

Could you try spelling out logic better? And put the input in one code tag. Do not put separate code tag for each line.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sum of column with condition

1 IT 50 2 IT 40 3 Finance 200 4 MP 30 5 MP 10 6 HQ 30 how to use awk to make it display it like this IT 90 MP 40 HQ 30 Finance 200 (1 Reply)
Discussion started by: minwei86
1 Replies

2. UNIX for Dummies Questions & Answers

How do I sum one column based on another column?

Hi, I am new to this forum and new to awk. I have a file that contains 2 columns. Heres an example of what it looks like: 10 + 20 + 40 + 50 - 70 - So the file is tab-delimited. What I want to do is add 10 to column 1 whenever column 2 is + and substract 10 from column 1... (1 Reply)
Discussion started by: phil_heath
1 Replies

3. Shell Programming and Scripting

to add special tag to a column based on column condition

Hi All, I have following html code <TR><TD>9</TD><TD>AR_TVR_TBS </TD><TD>85000</TD><TD>39938</TD><TD>54212</TD><TD>46</TD></TR> <TR><TD>10</TD><TD>ASCV_SMY_TBS </TD><TD>69880</TD><TD>33316</TD><TD>45698</TD><TD>47</TD></TR> <TR><TD>11</TD><TD>ARC_TBS ... (9 Replies)
Discussion started by: ckwan
9 Replies

4. UNIX for Dummies Questions & Answers

Sum based on column 1

i have file input aaa ccc,45567,rterw,1 bbb dcs,564543,hjghgh,1 aaa ccc,454,rterw,6 i want to sum based on column 1 expected output aaa ccc,7 bbb dcs,1 (4 Replies)
Discussion started by: radius
4 Replies

5. UNIX for Dummies Questions & Answers

Sum based on certain column

I have file 1 1/1/2013 A 553.0763397 96 16582 X1 X3 X5 X7 X9 1/1/2013 B 600.8333588 195 11992 X2 X3 X6 X7 X9 1/1/2013 B 459.8333588 195 11992 X1 X3 X6 X7 X9 1/2/2013 A 844.2973022 306 19555 X1 ... (12 Replies)
Discussion started by: radius
12 Replies

6. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

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

7. Shell Programming and Scripting

Check first column - average second column based on a condition

Hi, My input file Gene1 1 Gene1 2 Gene1 3 Gene1 0 Gene2 0 Gene2 0 Gene2 4 Gene2 8 Gene3 9 Gene3 9 Gene4 0 Condition: If the first column matches, then look in the second column. If there is a value of zero in the second column, then don't consider that record while averaging. ... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

8. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

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

9. Shell Programming and Scripting

Sum of a column as new column based on header in a script

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

10. UNIX for Beginners Questions & Answers

Sum in file based column

Hi All, I have a file as below and want to sum based on the id in the first column Input 10264;ATE; 12 10265;SES;11 10266AUT;50 10264;ATE;10 10265;SES;13 10266AUT;89 10264;ATE;1 10265;SES;15 10266AUT;78 Output 10264;ATE; 23 10265;SES;39 10266AUT;139 (6 Replies)
Discussion started by: arunkumar_mca
6 Replies
Template::Declare::TagSet(3pm)				User Contributed Perl Documentation			    Template::Declare::TagSet(3pm)

NAME
Template::Declare::TagSet - Base class for tag sets used by Template::Declare::Tags SYNOPSIS
package My::TagSet; use base 'Template::Declare::TagSet'; # returns an array ref for the tag names sub get_tag_list { [ qw( html body tr td table base meta link hr )] } # prevents potential naming conflicts: sub get_alternate_spelling { my ($self, $tag) = @_; return 'row' if $tag eq 'tr'; return 'cell' if $tag eq 'td'; } # Specifies whether "<tag></tag>" can be # combined to "<tag />": sub can_combine_empty_tags { my ($self, $tag) = @_; $tag =~ /^ (?: base | meta | link | hr ) $/x; } DESCRIPTION
Template::Declare::TagSet is the base class for declaring packages of Template::Delcare tags. If you need to create new tags for use in your templates, this is the base class for you! Review the source code of Template::Declare::TagSet::HTML for a useful example. METHODS
new( PARAMS ) my $tag_set = Template::Declare::TagSet->new({ package => 'Foo::Bar', namespace => undef, }); Constructor created by "Class::Accessor::Fast", accepting an optional hash reference of parameters. get_tag_list my $list = $tag_set->get_tag_list(); Returns an array ref for the tag names offered by a tag set. get_alternate_spelling( TAG ) $bool = $obj->get_alternate_spelling($tag); Returns true if a tag has an alternative spelling. Basically it provides a way to work around naming conflicts. For example, the "tr" tag in HTML conflicts with Perl's "tr" operator, and the "template" tag in XUL conflicts with the "template" sub exported by "Template::Declare::Tags". can_combine_empty_tags( TAG ) $bool = $obj->can_combine_empty_tags($tag); Specifies whether "<tag></tag>" can be combined into a single token, "<tag />". By default, all tags can be combined into a single token; override in a subclass to change this value where appropriate. For example, "Template::Declare::TagSet::HTML->can_combine_empty_tags('img')" returns true since "<img src="..." />" is always required for HTML pages. "Template::Declare::TagSet::HTML->can_combine_empty_tags('script')", on the other hand, returns false, since some browsers can't handle a single script token. ACCESSORS
This class has two read-only accessors: package my $package = $obj->package(); Retrieves the value of the "package" option set via the constructor. namespace my $namespace = $obj->namespace(); Retrieves the value of the "namespace" option set via the constructor. AUTHOR
Agent Zhang <agentzh@yahoo.cn>. SEE ALSO
Template::Declare::TagSet::HTML, Template::Declare::TagSet::XUL, Template::Declare::Tags, Template::Declare. perl v5.10.1 2010-12-08 Template::Declare::TagSet(3pm)
All times are GMT -4. The time now is 03:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy