Giter Site home page Giter Site logo

vin-parser's Introduction

vin-parser

Library that provides functions to work with VIN strings.

Install

vin-parser is available on PyPI and can be installed using pip.

$ pip install vin-parser

Usage

All the public functions are exported to the package namespace. We'll alias it as vp in the following examples.

>>> import vin_parser as vp

The functions check_no, seq_no, wmi, vds and vis return parts of the VIN string.

>>> vin = "1GYFK63878R248711"
>>> vp.check_no(vin)
'7'

Function check_no returns the VIN check digit, i.e. position 9 in the VIN string. It returns for all VINs, even for those that don't use the check digit schema.

>>> vp.wmi(vin)
'1GY'
>>> vp.vds(vin)
'FK6387'

Lowercase VINs are accepted:

>>> vp.vis(vin.lower())
'8R248711'

check_valid, is_valid and small_manuf are predicate functions, i.e. functions that return True or False. check_valid returns True if the VIN's check digit matches the computed value. is_valid returns True if the provided VIN is valid. Because the use of VIN check digit is not adopted worldwide, the check_valid test is not performed when verifing the validity of a VIN.

Functions continent, country, year and manuf parse the VIN and return the values. year returns a positive integer, while the others return a string with their name.

>>> vp.country(vin)
'United States'
>>> vp.year(vin)
2008
>>> vp.manuf(vin)
'General Motors USA'

Function parse calls all the other functions and returns the results in a dict if the provided VIN is valid. Function online_parse queries the nhtsa api with the provided VIN. Empty values are removed from the response and the rest are returned in a python dict. No other transformations are performed on the keys or values. Note that, unlike parse, online_parse doesn't check if the VIN is valid before sending it to the remote server.

The CHARS constant is a sorted string with all the valid characters of a VIN: A to Z, 1 to 9 and 0, except for I, O and Q.

vin-parser's People

Contributors

nighcoder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.