我有这个文件
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
我想添加具有相同 IP 地址的 column1。我想要像这样的输出
30, 44.66.44.55 , AD, AC , 112
20, 44.66.54.55 , AD, AC , 112
50, 44.66.64.55 , AD, AC , 112
我想用python做
我试过了
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]