Re: File parsing
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 22:42:53 -0600
On 11/29/2007 10:26 PM, vibgyorbits wrote:
k,very close...but this should fix almost everything!.
{ if (a[$2]=="") {
a[$2] = $1
}
else {
a[$2] = a[$2] - $1
print $2, a[$2]
a[$2]=""}
If you change the above to:
delete a[$2]
}
END {
for (i in a) {
if(a[i]!=""){ print i,a[i] }
then you can change the above to just:
print i,a[i]
since there'd be no unpopulated entries in "a".
}
}
You can simplify a little more too:
$2 in a { print $2, a[$2] - $1; delete a[$2]; next }
{ a[$2] = $1 }
END { for (i in a) print i, a[i] }
Regards,
Ed.
.
- 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
- Re: File parsing
- From: Bruce Gilmore
- Re: File parsing
- From: vibgyorbits
- File parsing
- Prev by Date: Re: File parsing
- Next by Date: filtering for identical field labels
- Previous by thread: Re: File parsing
- Next by thread: filtering for identical field labels
- Index(es):