Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import csv
- potholes_by_block = { }
- def make_block(address):
- '''
- Rewrite an address to strip address to 1000's\
- (10 blocks)
- '''
- parts = address.split()
- # For numbers like '5412' this makes '5XXX'
- parts[0] = parts[:-3] + 'XXX'
- return ' '.join(parts)
- f = open('potholes.csv')
- for row in csv.DictReader(f):
- status = row['STATUS']
- if status == 'Open':
- address = row['STREET ADDRESS']
- # Change address to block ???
- num = row['NUMBER OF POTHOLES FILLED ON BLOCK']
- # Tabulate
- block = make_block(address)
- if block not in potholes_by_address:
- # This is the first occurance of address
- potholes_by_block[block] = 1
- else:
- potholes_by_block[block] += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement