Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Sum a numbers of a row
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Roberto Zuelli  
View profile  
 More options Oct 15 2012, 12:57 pm
Newsgroups: comp.lang.awk
From: Roberto Zuelli <roberto...@gmail.com>
Date: Mon, 15 Oct 2012 09:57:05 -0700 (PDT)
Local: Mon, Oct 15 2012 12:57 pm
Subject: Re: Sum a numbers of a row
On Oct 15, 5:51 pm, "Ed Morton" <mortons...@gmail.com> wrote:

> Roberto Zuelli <roberto...@gmail.com> wrote:
> > Hello,
> > I've a txt.file like this:
> > A    1    2    3   0   0   6
> > B    0    0    0   0   0   0
> > J     0    0    0   1   0   9
> > D    0    0    0   0   0   0
> > O    0    99  0   1   0   9
> > Q    13  0    0   1   0   9
> > Z     0    0    5   8   0   8

> > The dimension of the table (rows and columns) aren't known, the goal
> > is make the sum of the elements for every row and print out the name
> > of the firtst row (i.e A,B,J...) with sum =0 (In this case B).
> > In the table there are more than different rows with all elemets =0
> > but my objective is to identify the first one.

> awk '{sum=0; for (i=2;i<=NF;i++) sum+=$i} !sum{print $1; exit}' file

> > I use awk in another language (GAMS) so the commands used are into
> > $onecho and $offecho.

> No idea what that means.

>    Ed.

> > Any idea?

> > Thanks

> > Roberto

> Posted usingwww.webuse.net- Hide quoted text -

> - Show quoted text -

$onecho and $offecho mean that I use awk as support language (I call
awk into GAMS to read files).

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.