Python: efficient way to loop through different lines of a data structure : I have a data structure like this:

1  ---  1  ---  100

2  ---  1  ---  200

3  ---  1  ---  100

1  ---  2  ---  300

2  ---  2  ---  100

3  ---  2  ---  400

I want to extract the data of third column corresponding to different values of second column, for example add three numbers in third column corresponding to number 1 in second column and so on. How should I do it efficiently in Python?
