def import_postcode_gss_codes(self, filename):

        with open(filename, "rb") as csvfile:
            with ImporterProgress(lines_in_file(filename)) as progress:
                datareader = csv.reader(csvfile)
                # skip the header row!
                datareader.next()
                for row in datareader:
                    self.import_row(row)
                    progress.increment(row[0])

            self.update_download(filename)
Example #2
0
    def import_local_authorities(self, filename):
        num_lines = lines_in_file(filename)
        self.graph = self._load_graph(filename)
        la_count = LocalAuthority.objects.count()
        log.info('Existing LocalAuthority count = ' + str(la_count))

        # all subject/object pairs which are related by a gssCode
        codes = self.graph.triples((None,
                                    URIRef("http://data.ordnancesurvey.co.uk/"
                                           "ontology/admingeo/gssCode"), None))

        with ImporterProgress(num_lines) as progress:
            for code_tuple in codes:
                self._import_gss_code(code_tuple)
                progress.increment('gssCode: ' + code_tuple[0])

        new_count = LocalAuthority.objects.count()
        log.info(str(new_count - la_count) + ' local authorities added')
        log.info('There are now ' + str(new_count) + ' local authorities')
    def import_local_authorities(self, filename):
        num_lines = lines_in_file(filename)
        self.graph = self._load_graph(filename)
        la_count = LocalAuthority.objects.count()
        log.info('Existing LocalAuthority count = ' + str(la_count))

        # all subject/object pairs which are related by a gssCode
        codes = self.graph.triples(
            (None, URIRef("http://data.ordnancesurvey.co.uk/"
                          "ontology/admingeo/gssCode"), None))

        with ImporterProgress(num_lines) as progress:
            for code_tuple in codes:
                self._import_gss_code(code_tuple)
                progress.increment('gssCode: ' + code_tuple[0])

        new_count = LocalAuthority.objects.count()
        log.info(str(new_count - la_count) + ' local authorities added')
        log.info('There are now ' + str(new_count) + ' local authorities')