reading a script and summing some values

I need help reading and summing some values in a file that looks like the following. This is an Oracle trace file. Oracle has as utility to do this,but it doesn't work properly unless my sql statement is done. I want to read the file and sum up some values to let me know how the query/job is progressing.

Here is an example

WAIT #5: nam='db file sequential read' ela= 384 file#=1790 block#=218096 blocks=1 obj#=408307 tim=8732259543169

The nam= value can vary.

I want to sum up the following
by
nam = '(this can vary)'
obj#=

So that would be the group by.

Then i want to sum up the number
blocks=

for each of the above. Note, that the number of blocks can be higher than 1. so its not just summing the number of rows and the nam= can be alot of different things.

but I only want to do this type of summation if there is a blocks=, some nam, so not have them and id want to handle that differently.