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]:
In [18]:
(suburb,num)=r.groups()
In [19]:
int(num)
Out[19]:
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)