Hey StackOverflow members, I have a function that parses a file and creates a multi-dimesnsional array containing the source IP, destination IP, and amount of packets transferred. What I must do is somehow calculate the total amount of packets transferred. So, in this multi-dimensional array, I have a few lines where the source and destination IP are the same, so in that case I have to turn all those lines into just one line and take the sum of the packets transferred.
So, for example, if you have a few lines that look like this:
192.167.1.1 10.0.0.1 500
192.167.1.1 10.0.0.1 35
192.167.1.1 10.0.0.1 5
It should become this:
192.167.1.1 10.0.0.1 540
The problem is I have no idea how to shorten my multi-dimensional array and add the sum of the third field and remove the rest of the lines that have the same source and destination IP. This is done on the Python language.
Thank you in advance.
Best regards, Babak