in reply to Merging partially duplicate lines

How could this be done?

Create a simple database with sqlite would be one way. Failing that, use a hash to aggregate records with the same key fields keeping a sum and count for each column

Note : I get 7 for the sum here

I       40      D       D       1       7
poj