> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Fri, 22 Jan 2016 00:12:18 +0000
> Subject: Re: [Tutor] Why is an OrderedDict not sliceable?
>
> On 22/01/16 00:00, Steven D'Aprano wrote:
>
> > Also, you have a problem -- what happens if the incomplete postcode is
> > missing the first digit? (I suppose for that case, you just have to do a
> > slow linear search.)
If the postcode letters are missing, I look up the insertion point for the
postcode digits. I then indeed use a linear search to loop through that postal
code 4-digits area. Then I use the apartment number to filter out impossible
street(s). Often postcodes for odd and even house numbers differ. So if, for
instance, I have postcode digits 1234, no postcode letters, and apartment
number 312, I can ignore all odd number ranges, and all ranges that do not
include 312 (many streets have just a few dozen numbers). I then end up with a
bunch of options, which I call candidates. Finally, I use
difflib.SequenceMatcher to try and select a record of which the "dirty" street
name, most closely resembles the standard street name in the list of
candidates. I did not consider what to do when one postcode letter is missing,
or when letters are transposed. I expect (and hope!) that the street/city
cannot be derived and that this record needs to be reviewed manually. And in
case you wondered: yes, it
sucks that all these corrections need to be done "after the fact". A good
reason to learn how to use Django or Flask to create a data entry screen and
start with crisp clean data :-)
> Which is why a different solution may be better suited.
> What about an in-memory SQLite table? Then you can use
> a LIKE based select and let the library do the hard work.
Ouch, I considered marshall and pickle to cache the data, because running the
query on MS SQL takes more time than I like. But I am embarrassed to say I did
not even consider SQLite. I will reconsider this. Thank you!
> Just a thought.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor