Skip to content

Instantly share code, notes, and snippets.

@rvause
Created January 3, 2013 15:15
Show Gist options
  • Select an option

  • Save rvause/4444207 to your computer and use it in GitHub Desktop.

Select an option

Save rvause/4444207 to your computer and use it in GitHub Desktop.
Make random addresses to fill out data
# -*- coding: utf-8 -*-
import random
STREET_NAMES = [
'Steve',
'Thyme',
'Rigby',
'Chedder',
'Priston',
'Meril',
'Turnball',
'Quentin',
'Drevend',
'Dorchester',
'Namy',
'Triforce',
'Merident',
'Percel',
'Formagont',
'Zubeki',
'Some',
]
STREET_ENDS = [
'Road',
'Drive',
'Way',
'Street',
'Lane',
'Grove',
'Place',
'Blvd'
]
DISTRICTS = [
'Bayswater',
'Belgravia',
'Bloomsbury',
'Clerkenwell',
'The City',
'Holborn',
'Mayfair',
'Paddington',
'Pimlico',
'Soho',
'St. James\'s',
'St. John\'s Wood',
'Trafalgar Square',
'The West End',
'Westminster',
'Whitehall',
'Camden',
'Euston',
'Hampstead',
'Highgate',
'Kentish Town',
'Kings Cross',
'Islington',
'Stoke Newington',
'St. Pancras',
'Wembley',
'Brixton',
'Dulwich',
'Forest Hill',
'Greenwich',
'Lambeth',
'The South Bank',
'Southwark',
'Wandsworth',
'Wimbledon',
'Brentford',
'Chiswick',
'Ealing',
'Fulham',
'Hammersmith',
'Hampton',
'Isleworth',
'Kew',
'Richmond',
'Twickenham',
'Docklands',
'Bethnal Green',
'Shoreditch',
'Spitalfields',
'Whitechapel',
'Walthamstow',
'Mile End',
'Bow',
'Stratford'
]
CITIES = [
'Aberdeen',
'Armagh',
'Bangor',
'Bath',
'Belfast',
'Birmingham',
'Bradford',
'Brighton and Hove',
'Bristol',
'Cambridge',
'Canterbury',
'Cardiff',
'Carlisle',
'Chester',
'Chichester',
'City of London',
'Coventry',
'Derby',
'Dundee',
'Durham',
'Edinburgh',
'Ely',
'Exeter',
'Glasgow',
'Gloucester',
'Hereford',
'Inverness',
'Kingston upon Hull',
'Lancaster',
'Leeds',
'Leicester',
'Lichfield',
'Lincoln',
'Lisburn',
'Liverpool',
'Londonderry',
'Manchester',
'Newcastle upon Tyne',
'Newport',
'Newry',
'Norwich',
'Nottingham',
'Oxford',
'Peterborough',
'Plymouth',
'Portsmouth',
'Preston',
'Ripon',
'Salford',
'Salisbury',
'Sheffield',
'Southampton',
'St Albans',
'St Davids',
'Stirling',
'Stoke-on-Trent',
'Sunderland',
'Swansea',
'Truro',
'Wakefield',
'Wells',
'Westminster',
'Winchester',
'Wolverhampton',
'Worcester',
'York'
]
COUNTIES = [
'Avon',
'Bedfordshire',
'Berkshire',
'Borders',
'Buckinghamshire',
'Cambridgeshire',
'Central',
'Cheshire',
'Cleveland',
'Clwyd',
'Cornwall',
'County Antrim',
'County Armagh',
'County Down',
'County Fermanagh',
'County Londonderry',
'County Tyrone',
'Cumbria',
'Derbyshire',
'Devon',
'Dorset',
'Dumfries and Galloway',
'Durham',
'Dyfed',
'East Sussex',
'Essex',
'Fife',
'Gloucestershire',
'Grampian',
'Greater Manchester',
'Gwent',
'Gwynedd County',
'Hampshire',
'Herefordshire',
'Hertfordshire',
'Highlands and Islands',
'Humberside',
'Isle of Wight',
'Kent',
'Lancashire',
'Leicestershire',
'Lincolnshire',
'Lothian',
'Merseyside',
'Mid Glamorgan',
'Norfolk',
'North Yorkshire',
'Northamptonshire',
'Northumberland',
'Nottinghamshire',
'Oxfordshire',
'Powys',
'Rutland',
'Shropshire',
'Somerset',
'South Glamorgan',
'South Yorkshire',
'Staffordshire',
'Strathclyde',
'Suffolk',
'Surrey',
'Tayside',
'Tyne and Wear',
'Warwickshire',
'West Glamorgan',
'West Midlands',
'West Sussex',
'West Yorkshire',
'Wiltshire',
'Worcestershire'
]
POSTCODE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def get_line_1():
return '%s %s %s' % (
random.randint(1, 2000),
random.choice(STREET_NAMES),
random.choice(STREET_ENDS)
)
def get_line_2():
return random.choice(DISTRICTS)
def get_city():
return random.choice(CITIES)
def get_county():
return random.choice(COUNTIES)
def get_postcode():
return '%s%s %s%s' % (
''.join([random.choice(POSTCODE_CHARS) for i in range(2)]),
random.randint(1, 99),
random.randint(1, 99),
''.join([random.choice(POSTCODE_CHARS) for i in range(2)])
)
def get_address():
return [
get_line_1(),
get_line_2(),
get_city(),
get_county(),
get_postcode()
]
if __name__ == '__main__':
print get_address()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment