In [11]:
import csv
import re

In [12]:
fp=open('output.csv','r')

reader=csv.reader(fp)


In [13]:
suburb_dict={}

In [14]:
text='"$745,000",111 Kelleway Avenue,Nicholls,house,Sold on 22 Feb 2016,4,2,2,http://www.realestate.com.au/sold/property-house-act-nicholls-121736730,https://www.realestate.com.au/sold/in-2912/list-2185'

In [15]:
pattern=re.compile(r'(?:in\-)(\d{4})(?:\/list\-)(\d+)')

In [16]:
r=pattern.search(text)

In [17]:
r.groups()


Out[17]:
('2912', '2185')

In [18]:
(suburb,num)=r.groups()

In [19]:
int(num)


Out[19]:
2185

In [20]:
for line in fp:
    r=pattern.search(line)
    if r:
        (suburb,num)=r.groups()
        if suburb not in suburb_dict.keys():
            suburb_dict[suburb]=int(num)
        else:
            value=suburb_dict[suburb]
            if int(num) > value:
                suburb_dict[suburb]=int(num)

In [21]:
print(suburb_dict)


{'2905': 129, '2914': 100, '2602': 139, '2904': 53, '2603': 50, '2906': 103, '2606': 43, '2911': 12, '2912': 2185, '2600': 42, '2605': 46, '2611': 104, '2607': 60, '2913': 146, '2612': 71, '2900': 12, '2615': 191, '2604': 65, '2609': 2, '2903': 37, '2610': 2, '2902': 199, '2601': 14, '2901': 2, '2614': 70}