Re: suggestions for VIN parsing

2014-12-29 Thread Denis McMahon
On Sun, 28 Dec 2014 16:27:20 -0700, Vincent Davis wrote: On Fri, Dec 26, 2014 at 12:15 PM, Denis McMahon denismfmcma...@gmail.com wrote: Note, I think the 1981 model year ran KCA - DCA prefixes, not as shown on the website you quoted. ​Denis, Regarding the KCA - DCA prefixes, do you

Re: suggestions for VIN parsing

2014-12-29 Thread Vincent Davis
On Mon, Dec 29, 2014 at 7:47 AM, Denis McMahon denismfmcma...@gmail.com wrote: K .. D would be the appropriate month prefixes for the 1981 model year, but if both the 1981 and 1982 model years used DA as a year prefix, there would be some prefixes that appeared twice, in the 1981 model year

Re: suggestions for VIN parsing

2014-12-29 Thread Vincent Davis
On Sun, Dec 28, 2014 at 11:50 PM, Rick Johnson rantingrickjohn...@gmail.com wrote: 3. I see that you are utilizing regexps to aid in the logic, and although i agree that regexps are overkill for this problem (since it could technically be solved with string methods) if *I* had to solve this

Re: suggestions for VIN parsing

2014-12-29 Thread Rick Johnson
On Monday, December 29, 2014 10:58:59 AM UTC-6, Vincent Davis wrote: Rick, Thanks for your suggestions, I was just starting version2 and wanted to do something like you suggest. Another question. I what to change the logic so that rather than return THE match it return all matches. I want to

Re: suggestions for VIN parsing

2014-12-29 Thread Rick Johnson
On Monday, December 29, 2014 12:27:33 PM UTC-6, Rick Johnson wrote: [...] [Addendum] WHEN LOGICAL AND SUBJECTIVE CONSTRUCTS INTERSECT, SEMANTIC WARS ARE WAGED! I

Re: suggestions for VIN parsing

2014-12-29 Thread Rick Johnson
[Addendum #2] WHO'S RESPONSIBLE FOR THE SEMANTIC WARS? I've always believed in the philosophy of: Responsibility to the responsible. After reading that statement, a

Re: suggestions for VIN parsing

2014-12-29 Thread Rick Johnson
[ADDENDUM #3] I got off on a tangent in that last post, now i intend to re-focus the discussion. OPTION 1: Define the keys as ranges and the values as years. From the perspective of the mapping, the semantic order is inversed. The range has no semantical meaning UNLESS it is

Re: suggestions for VIN parsing

2014-12-29 Thread Chris Angelico
On Tue, Dec 30, 2014 at 10:45 AM, Rick Johnson rantingrickjohn...@gmail.com wrote: [ADDENDUM #3] This reminds me of the transcript of Still Alive at the end of Portal. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: suggestions for VIN parsing

2014-12-28 Thread Vincent Davis
On Fri, Dec 26, 2014 at 12:15 PM, Denis McMahon denismfmcma...@gmail.com wrote: Note, I think the 1981 model year ran KCA - DCA prefixes, not as shown on the website you quoted. ​Denis, Regarding the KCA - DCA prefixes, do you have a source as to why you think this? Here is what I have so

Re: suggestions for VIN parsing

2014-12-28 Thread Rick Johnson
On Sunday, December 28, 2014 5:34:11 PM UTC-6, Vincent Davis wrote: [snip: code sample with Unicode spaces! Yes, *UNICODE SPACES*!] Oh my! Might i offer some suggestions to improve the readability of this code? 1. Indexing is syntactically noisy, so if you find yourself fetching the same

Re: suggestions for VIN parsing

2014-12-28 Thread Rick Johnson
On Monday, December 29, 2014 12:50:39 AM UTC-6, Rick Johnson wrote: [EDIT] 3. Now you can write some fairly simple logic. prog = re.compile(pat1|pat2|pat3...) def parse_vin(vin): match = prog.search(vin) if match: gname = # Fetch the groupname from the

Re: suggestions for VIN parsing

2014-12-26 Thread Denis McMahon
On Thu, 25 Dec 2014 17:02:33 -0700, Vincent Davis wrote: I would like to parse the VIN, frame and engine numbers found on this page (below). First of all you need to define the number of different patterns that are possible: eg: H + 3-5 digits - twins Unit 350cc 500cc '57 - '69 3 (or

suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
I would like to parse the VIN, frame and engine numbers found on this page (below). I don't really know any regex, I have looked a little at pyparsing. I have some other similar numbers to. I am looking for suggestions, which tool should I learn, how should I approach this.

Re: suggestions for VIN parsing

2014-12-25 Thread Dan Stromberg
On Thu, Dec 25, 2014 at 4:02 PM, Vincent Davis vinc...@vincentdavis.net wrote: I would like to parse the VIN, frame and engine numbers found on this page (below). I don't really know any regex, I have looked a little at pyparsing. I have some other similar numbers to. I am looking for

Re: suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
These are vintage motorcycles so the VIN's are not like modern VIN's these are frame numbers and engine number. I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. Vincent Davis 720-301-3003 On Thu, Dec 25, 2014 at 5:56

Re: suggestions for VIN parsing

2014-12-25 Thread Tim Chase
On 2014-12-25 17:59, Vincent Davis wrote: These are vintage motorcycles so the VIN's are not like modern VIN's these are frame numbers and engine number. I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. While I've

Re: suggestions for VIN parsing

2014-12-25 Thread Ben Finney
Vincent Davis vinc...@vincentdavis.net writes: I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. So the page has a collection of tables which the reader can use to manually look up the VIN, or elements of the VIN, to

Re: suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
Tim and Ben, Thanks for your input, I am working on it now and will come back when I have questions. Any comment on using pyparsing VS regex Vincent Davis 720-301-3003 On Thu, Dec 25, 2014 at 7:18 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Vincent Davis vinc...@vincentdavis.net writes:

Re: suggestions for VIN parsing

2014-12-25 Thread Tim Chase
On 2014-12-25 19:58, Vincent Davis wrote: Any comment on using pyparsing VS regex If the VIN had any sort of regular grammar (especially if it involved nesting) then pyparsing would have value. I defaulted to regexp (1) because it's available out of the box, and (2) while it might be overkill,

Re: suggestions for VIN parsing

2014-12-25 Thread Skip Montanaro
You're extracting structured data from an html file. You might want to look at the lxml.etree module. (I think that's where ElementTree landed when it was adopted into the stdlib). Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: suggestions for VIN parsing

2014-12-25 Thread Ben Finney
Vincent Davis vinc...@vincentdavis.net writes: Any comment on using pyparsing VS regex A full-blown parser (with ‘pyparsing’) is overkill for this. Even regular expressions isn't needed. The built-in text type (‘str’) in Python 3 should have everything you need; you only need to match