Skip to content

Checker: Fields Extraction Support #6

Closed
@Arg0s1080

Description

Several people have asked me by email how they get the fields (names, surnames, nationality, type of document, etc. strings) without access to a protected member of the class. Therefore I have created the fields() method for td1, td2, td3, mrva and mrvb.

For example:

from mrz.checker.td1 import TD1CodeChecker, get_country

mrz_td1 = ("IDD<<ID98754015<<<<<<<<<<<<<<<\n" 
           "8205122M1906224D<<<<<<<<<<<<<6\n" 
           "SCHNEIDER<WEBER<<NORBERT<<<<<<")

td1_check = TD1CodeChecker(mrz_td1)

To get identifiers, country, and date of birth....

Before (accessing to protected members of the class):

print(td1_check._identifier)
print(td1_check._country)
print(td1_check._birth_date)
Output:
SCHNEIDER<WEBER<<NORBERT<<<<<<
D<<
820512

Now:

fields() method returns a namedtuple with all fields strings:

td1_check.fields()
Returns:
fields(document_type='ID', country='D', document_number='ID9875401', document_number_hash='5', optional_data='', birth_date='820512', birth_date_hash='2', sex='M', expiry_date='190622', expiry_date_hash='4', nationality='D', optional_data_2='', final_hash='6', surname='SCHNEIDER WEBER', name='NORBERT')

So, to get given names, surnames and birth date:

fields = td1_check.fields()
print(fields.surname)
print(fields.name)
print(get_country(fields.country))
print(fields.birth_date)
Output:
SCHNEIDER WEBER
NORBERT
Germany
820512

Available fields

id cards and others td1's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash,
 optional_data_2 and final_hash

td2's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash
and final_hash

Passports and other td3's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash,
optional_data_hash and final_hash

Any Visa (mrva & mrvb)

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash and document_number_hash

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

CHECKERMRZ.CHECKER IssuesenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions