123456789,9.09,AAAA
231456788,0.99,BBBB
098798765,1.99,CCCC
098750109,9.68,BBBB
098709866,0.01,AAAA
And I need the out put to disregard the first field and just group the
3rd field and sum the amount(field 2) for each group ie
Code AAAA Amount 9.10
Code BBBB Amount 10.67
Code CCCC 1.99
Any help on this would be greatly appreciated
> Hi guys, basically I have a file format of
>
>
> 123456789,9.09,AAAA
> 231456788,0.99,BBBB
> 098798765,1.99,CCCC
> 098750109,9.68,BBBB
> 098709866,0.01,AAAA
>
> And I need the out put to disregard the first field and just group the
> 3rd field and sum the amount(field 2) for each group ie
>
> Code AAAA Amount 9.10
> Code BBBB Amount 10.67
> Code CCCC 1.99
Assuming you don't care about output ordering, you can do
awk -F, '{t[$3]+=$2}END{for(i in t)printf "Code %s Amount %.2f\n", i, t[i]}'
with GNU awk, you can even force ordering by code of the output by setting
the WHINY_USERS environmental variable (to any value).
mr/mrs/ms pk has 300+ posts to comp.lang.awk so he/her/it has much to
say that would be good to hear.
but pk's email address ends in "invalid" so i'm guessing if i email
him/her/it then that post will not go anywhere.
on the condition that i never broadcast his/her/it's email, would "pk"
care to contact me directly either at ma...@awk.info or t...@menzies.us?
thanks!
t