Converting ordnance survey coordinates into templates within wikipedia markup

September 15, 2011 at 12:10 am Leave a comment

Use the following script (Uses osgb from pypi)

#!/usr/bin/python
import osgb.convert
import sys
import re

def convert(x):
    long, lat = osgb.convert.osgb_to_lonlat(x.group(0))
    return '%s ({{coord|%.3f|%.3f|source:enwiki-osgb36(%s)}})' % (x.group(0), lat, long, x.group(0))


data = sys.stdin.read()
print re.sub('[A-Z][A-Z][0-9]{6}', convert, data)
Advertisements

Entry filed under: Uncategorized.

Screen scraping using a headless selenium Problems when trying to use gmail for mail forwarding

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


September 2011
M T W T F S S
« Jul   Oct »
 1234
567891011
12131415161718
19202122232425
2627282930  

%d bloggers like this: