Permalink
Browse files

Use slightly better path for when running from elsewhere.

  • Loading branch information...
dracos committed Nov 30, 2012
1 parent c88ae40 commit d4c45ac2147c9d11d49357a2e0f018bc254e9289
@@ -2,6 +2,7 @@
# containing only the new ones from a modern Boundary-Line.
import csv
+import os.path
from django.core.management.base import NoArgsCommand
from mapit.models import Area, CodeType
from psycopg2 import IntegrityError
@@ -26,13 +27,13 @@ class Command(NoArgsCommand):
help = 'Inserts the old ONS codes into mapit'
def handle_noargs(self, **options):
- mapping = csv.reader(open('../data/UK/BL-2010-10-code-change.csv'))
+ mapping = csv.reader(open(os.path.dirname(__file__) + '/../../../data/UK/BL-2010-10-code-change.csv'))
mapping.next()
for row in mapping:
new_code, name, old_code = row[0], row[1], row[3]
process(new_code, old_code)
- mapping = csv.reader(open('../data/UK/BL-2010-10-missing-codes.csv'))
+ mapping = csv.reader(open(os.path.dirname(__file__) + '/../../../data/UK/BL-2010-10-missing-codes.csv'))
mapping.next()
for row in mapping:
type, new_code, old_code, name = row
@@ -14,6 +14,7 @@
# classification, Pre October 2006 PCO
import csv
+import os.path
from django.db import transaction
from mapit.models import Area
from mapit.management.commands.mapit_import_postal_codes import Command
@@ -29,7 +30,7 @@ def handle_label(self, file, **options):
self.euro_area = Area.objects.get(country__code='N', type__code='EUR')
# Read in new ONS code to names, look up existing wards and Parliamentary constituencies
- snac = csv.reader(open('../data/UK/snac-2009-ni-cons2ward.csv'))
+ snac = csv.reader(open(os.path.dirname(__file__) + '/../../../data/UK/snac-2009-ni-cons2ward.csv'))
snac.next()
code_to_area = {}
for parl_code, parl_name, ward_code, ward_name, district_code, district_name in snac:
@@ -5,6 +5,7 @@
# NI has any boundary changes.
import csv, re
+import os.path
from django.contrib.gis.geos import Point
from django.core.management.base import NoArgsCommand
from mapit.models import Postcode, Area, Generation, Country, Type, CodeType, NameType
@@ -31,7 +32,7 @@ def handle_noargs(self, **options):
euro_area.names.get_or_create(type=name_type, name='Northern Ireland')
# Read in ward name -> electoral area name/area
- ni_eas = csv.reader(open('../data/UK/ni-electoral-areas.csv'))
+ ni_eas = csv.reader(open(os.path.dirname(__file__) + '/../../../data/UK/ni-electoral-areas.csv'))
ni_eas.next()
ward_to_electoral_area = {}
e = {}
@@ -50,7 +51,7 @@ def handle_noargs(self, **options):
ward_to_electoral_area.setdefault(district, {})[ward] = e[electoral_area]
# Read in new ONS code to names
- snac = csv.reader(open('../data/UK/snac-2009-ni-cons2ward.csv'))
+ snac = csv.reader(open(os.path.dirname(__file__) + '/../../../data/UK/snac-2009-ni-cons2ward.csv'))
snac.next()
code_to_area = {}
for parl_code, parl_name, ward_code, ward_name, district_code, district_name in snac:

0 comments on commit d4c45ac

Please sign in to comment.