I have this file
10, 44.66.44.55 , AD, AC , 112
10, 44.66.54.55 , AD, AC , 112
10, 44.66.44.55 , AD, AC , 112
50, 44.66.64.55 , AD, AC , 112
10, 44.66.54.55 , AD, AC , 112
10, 44.66.44.55 , AD, AC , 112
I want to add the column1 with same ip address. i want the output like
30, 44.66.44.55 , AD, AC , 112
20, 44.66.54.55 , AD, AC , 112
50, 44.66.64.55 , AD, AC , 112
I want to do in python
I tried
import re
import collections
a = collections.Counter()
with open("temp.txt", "r") as f:
for line in f.readlines():
list = line.split()
a[list[1]] += int(list[0])
print list[1]
collections.Counter.