The following code will do what you want:
import re
a = {}
with open('input.txt', 'rb') as f:
for line in f:
x = re.search(r'<([^,]+),\s?([^>]+)>', line)
x,y = float(x.group(1)), float(x.group(2))
if x in a:
a[x].append(y)
else:
a[x] = [y]
for key in a:
a[key] = sum(a[key])/len(a[key])
print a
with open('output.txt', 'wb') as f:
for i,j in a.items():
f.write('<'+str(i)+', '+str(j)+'>\n')
[input.txt]
<122, 5>
<185, 5>
<122,4.5>
[output.txt]
<122, 4.75>
<185, 5>