Re: File parsing
- From: Bruce Gilmore <bruce84@xxxxxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 21:42:43 -0600
vibgyorbits wrote:
Or probably, my data set cal also be:
10 abc
20 abcc
30 abcd
40 xycz
42 wxy
5 abc
100 abc
20 abcd
30 abcc
99 abc
In this case: for abc, it should be
5 abc
1 abc
<<< Need to print 2 times for abc, as it occurs 4 times.
I'm sure there will be better solutions (which I'm eagerly awaiting from this great NG) but here's my stab at it.
#################################
{ if (a[$2]=="") {
a[$2] = $1
}
else {
a[$2] = a[$2] - $1
print $2, a[$2]
a[$2]=""}
}
#################################
.
- Follow-Ups:
- Re: File parsing
- From: vibgyorbits
- Re: File parsing
- References:
- File parsing
- From: vibgyorbits
- Re: File parsing
- From: Ed Morton
- Re: File parsing
- From: vibgyorbits
- Re: File parsing
- From: vibgyorbits
- Re: File parsing
- From: vibgyorbits
- File parsing
- Prev by Date: Re: File parsing
- Next by Date: Re: File parsing
- Previous by thread: Re: File parsing
- Next by thread: Re: File parsing
- Index(es):
Relevant Pages
|