Ignore:
Timestamp:
Sep 5, 2009, 5:56:14 PM (10 years ago)
Author:
Nick Burch
Message:

New dracos format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/generic-python-import/generic_importer.py

    r686 r700  
    326326                        url="http://www.dracos.co.uk/play/locating-postboxes/export.php?rm=1"
    327327                )
    328                 self.valid_pc = re.compile("^([A-Z]+\d+)(\d[A-Z][A-Z])$")
     328                self.valid_pc = re.compile("^([A-Z]+\d+\s*[A-Z]?)\s*(\d[A-Z][A-Z])$")
    329329
    330330        def process_line(self,line):
     
    336336                        return
    337337
     338                # Ref, Postcode, Loc1, Loc2, Latitude, Longitude, last m-f, last sat
    338339                parts = line.split("\t")
    339                 if not len(parts) == 6:
     340                if len(parts) == 6 or len(parts) == 7 or len(parts) == 8:
     341                        pass
     342                else:
    340343                        print "Invalid line '%s'" % line
    341344                        return
     
    348351                match = self.valid_pc.match(parts[1])
    349352                if not match:
     353                        #print "Invalid - %s" % parts[1]
    350354                        return
    351355                outer, inner = match.groups()
     356
     357                # Seems to be things like "W1 C2DN" not "W1C 2DN", fix
     358                outer = outer.replace(" ", "")
     359                #print "%s ** %s" % (outer,inner)
    352360
    353361                pc = {}
Note: See TracChangeset for help on using the changeset viewer.