henrywilson
asked on
sort/merge and total matching key records using awk.
I have two (or more) files which have the same structure
i.e.
file1
01,ann,2,3,6,.......
01,tim,9,8,7,.......
01,max,1,1,1,.....
etc
file2
01,ann,6,7,8,.........
01,tim,1,2,3,.......
01,jenny,2,2,2,....
etc
I want to merge these files into one but only have one record per person, with totalled values.
outfile
01,ann,8,10,14,.......
01,jenny,2,2,2,....
01,max,1,1,1,....
01,tim,10,10,10,.......
etc
There are over 2000 people on each flle and 70 variables to be totalled for each.
It is fairly straightforward to sort /merge the files and I can produce a an overall sum total of each column, but how do I just summarise multiple records for each person ?.
Needs to be achieved using awk.
Any help greatly appreciated.
i.e.
file1
01,ann,2,3,6,.......
01,tim,9,8,7,.......
01,max,1,1,1,.....
etc
file2
01,ann,6,7,8,.........
01,tim,1,2,3,.......
01,jenny,2,2,2,....
etc
I want to merge these files into one but only have one record per person, with totalled values.
outfile
01,ann,8,10,14,.......
01,jenny,2,2,2,....
01,max,1,1,1,....
01,tim,10,10,10,.......
etc
There are over 2000 people on each flle and 70 variables to be totalled for each.
It is fairly straightforward to sort /merge the files and I can produce a an overall sum total of each column, but how do I just summarise multiple records for each person ?.
Needs to be achieved using awk.
Any help greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER