Command line tools

The following command line tools are installed as part of the package

mastercard ipm tools

mci_ipm_to_csv

Converts Mastercard IPM files to csv format

Default input file encoding is latin-1. See Python encodings for other options.

Note

Fields defined as datetime in the ISO8583 config will be rendered in the CSV as ISO 8601 calendar date format.

usage: mci_ipm_to_csv [-h] [-o OUT_FILENAME] [--in-encoding IN_ENCODING]
                      [--out-encoding OUT_ENCODING]
                      [--no1014blocking] [--config-file CONFIG_FILE] [--version]
                      in_filename

Mastercard IPM to CSV

positional arguments:
  in_filename

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_FILENAME, --out-filename OUT_FILENAME
  --in-encoding IN_ENCODING
  --out-encoding OUT_ENCODING
  --no1014blocking
  --config-file CONFIG_FILE
                        File containing cardutil configuration - JSON format
  --version             show program's version number and exit

mci_ipm_param_encode

Changes the encoding of a Mastercard IPM parameter file

usage: mci_ipm_param_encode [-h] [-o OUT_FILENAME] [--in-encoding IN_ENCODING]
                            [--out-encoding OUT_ENCODING]
                            [--no1014blocking]
                            [--in-format {vbs,1014}][--out-format {vbs,1014}]
                            [--version]
                            in_filename

Mastercard IPM param file encoder

positional arguments:
  in_filename

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_FILENAME, --out-filename OUT_FILENAME
  --in-encoding IN_ENCODING
  --out-encoding OUT_ENCODING
  --no1014blocking
  --in-format {vbs,1014}
  --out-format {vbs,1014}
  --version             show program's version number and exit

mci_ipm_encode

Changes the encoding of a Mastercard IPM file

usage: mci_ipm_encode [-h] [-o OUT_FILENAME]
                      [--in-encoding IN_ENCODING] [--out-encoding OUT_ENCODING]
                      [--no1014blocking]
                      [--in-format {vbs,1014}][--out-format {vbs,1014}]
                      [--version]
                      in_filename

Mastercard IPM file encoder

positional arguments:
  in_filename

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_FILENAME, --out-filename OUT_FILENAME
  --in-encoding IN_ENCODING
  --out-encoding OUT_ENCODING
  --no1014blocking
  --in-format {vbs,1014}
  --out-format {vbs,1014}
  --version             show program's version number and exit

mci_csv_to_ipm

Creates a Mastercard IPM file from a csv file

Note

Parsing of string dates

Parsing of dates contained in the input CSV file will be different based on:

  • if you have the python-dateutil library installed – it will use its date parser

  • if you are using python 3.7 or above - will use datetime.fromisodate function

  • Otherwise, it will use a simple parser that will attempt 3 patterns:

    ccyy-mm-dd hh:mm:ss
    ccyy-mm-dd hh:mm
    ccyy-mm-dd
    

It is recommended that if you require more than basic ISO 8601 calendar date parsing, that you install the python-dateutil module.

Warning

Inclusion of both PDS and DE fields that contain PDS fields

If your CSV file contains both PDS fields (PDSxxxx) and DE fields that are used to store PDS fields (like DE48) then the contents of DE48 will dropped and the PDS fields provided will overwrite the value.

You should either provide ALL PDS fields or provide the DE fields that contain PDS fields but not both.

usage: mci_csv_to_ipm [-h] [-o OUT_FILENAME] [--in-encoding IN_ENCODING]
                      [--out-encoding OUT_ENCODING]
                      [--no1014blocking] [--config-file CONFIG_FILE] [--version]
                      in_filename

CSV to Mastercard IPM

positional arguments:
  in_filename

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_FILENAME, --out-filename OUT_FILENAME
  --in-encoding IN_ENCODING
  --out-encoding OUT_ENCODING
  --no1014blocking
  --config-file CONFIG_FILE
                        File containing cardutil configuration - JSON format
  --version             show program's version number and exit

mci_ipm_param_to_csv

Extracts parameter tables from the IPM parameter extracts files

usage: mci_ipm_param_to_csv [-h] [-o OUT_FILENAME]
                            [--in-encoding IN_ENCODING] [--out-encoding OUT_ENCODING]
                            [--no1014blocking] [--expanded]
                            [--config-file CONFIG_FILE] [--version]
                            in_filename table_id

Mastercard IPM parameter file to CSV

positional arguments:
  in_filename           IPM Parameter file to process
  table_id              Parameter table to extract

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_FILENAME, --out-filename OUT_FILENAME
  --in-encoding IN_ENCODING
  --out-encoding OUT_ENCODING
  --no1014blocking
  --expanded
  --config-file CONFIG_FILE
                        File containing cardutil configuration - JSON format
  --version             show program's version number and exit

config file

Command line tools can allow passing of configuration to customise the tool behavior.

There are 2 ways the custom configuration can be provided:

  • set --config-file to location of file containing configuration

  • set CARDUTIL_CONFIG environment variable to point to folder containing cardutil.json file

The format is a JSON object containing the config variable from the package config.py file. See cardutil.config.

Warning

This is an example only. Please refer to cardutil.config for full details.

{
    "bit_config": {
        "1": {"field_name": "Bitmap secondary", "field_type": "FIXED", "field_length": 8},
        "other bits": {},
        "127": {"field_name": "Network data", "field_type": "LLLVAR", "field_length": 0}
    },
    "output_data_elements": [
        "MTI", "DE2", "DE3", "DE4", "DE12", "DE14", "DE22", "DE23", "DE24", "DE25", "DE26",
        "DE30", "DE31", "DE33", "DE37", "DE38", "DE40", "DE41", "DE42", "DE48", "DE49",
        "DE50", "DE63", "DE71", "DE73", "DE93", "DE94", "DE95", "DE100", "PDS0023",
        "PDS0052", "PDS0122", "PDS0148", "PDS0158", "PDS0165", "DE43_NAME", "DE43_SUBURB",
        "DE43_POSTCODE", "ICC_DATA"
    ],
    "mci_parameter_tables": {
        "IP0006T1": {
            "card_program_id": {"start": 19, "end": 22},
            "data_element_id": {"start": 22, "end": 25},
            "data_element_name": {"start": 25, "end": 82},
            "data_element_format": {"start": 82, "end": 85}
        }
    }
}