Archive for September, 2011
Converting ordnance survey coordinates into templates within wikipedia markup
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)