adelosa / cardutil

Payment cards tools including ISO8583 parser and Mastercard IPM files processing
MIT License
24 stars 4 forks source link

Convert IPM ASCII file to EBCDIC 1014 blocking #3

Closed charisad closed 2 years ago

charisad commented 2 years ago

HOW DO I GO ABOUT THE BELOW PROCESS? 1014 blocked file format This is the same as VBS format with 1014 blocking applied.

The VBS data is blocked into lengths of 1012, and an additional 2 x’40’ characters are appended at each block.

Finally, the total file length is made a multiple of 1014 with the final incomplete record being filled with the x’40’ character

adelosa commented 2 years ago

The tool supports 1014 and VBS but I don't think I have ever wanted to convert between formats and encodings before - you could use the library to create such a converter if you wanted.

Otherwise you could use mci_ipm_to_csv --in-encoding ascii --no1014blocking to get the file to CSV then mci_csv_to_ipm --out-encoding cp500 to generate it in the new format. Let me know how you go.

charisad commented 2 years ago

CMD TRACE - SAYING Keyerror 16. csv file was created but no data added, please advise

C:\Users\HP\Desktop>mci_ipm_to_csv --in-encoding ascii --no1014blocking SampleOutput2022050414531881_MASTERCARD.txt

Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\mci_ipm_to_csv.exe__main__.py", line 7, in File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\cli\mci_ipm_to_csv.py", line 9, in cli_entry cli_run(vars(cli_parser().parse_args())) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\cli\mci_ipm_to_csv.py", line 21, in cli_run mci_ipm_to_csv(in_ipm=in_ipm, out_csv=out_csv, config=config, kwargs) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\cli\mci_ipm_to_csv.py", line 49, in mci_ipm_to_csv dicts_to_csv( File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\outputter.py", line 22, in dicts_to_csv for item in filtered_data_list: File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\outputter.py", line 36, in return (filter_dictionary(item, field_list) for item in data_list) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\mciipm.py", line 317, in next__ return iso8583.loads(vbs_record, encoding=self.encoding, iso_config=self.iso_config) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\iso8583.py", line 129, in loads return _iso8583_to_dict(b, iso_config, encoding, hex_bitmap) File "C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cardutil\iso8583.py", line 180, in _iso8583_to_dict bit_config[str(bit)], KeyError: '16'

charisad commented 2 years ago

I have managed to create an EBCDIC IPM FILE, HOW DO I MAKE IT 1014 BLOCKING WITH CARDUTIL?

adelosa commented 2 years ago

By default, the file will be 1014 blocked. You use the --no1014blocking command to use VBS format instead.

charisad commented 2 years ago

By default, the file will be 1014 blocked. You use the --no1014blocking command to use VBS format instead.

Okay will give you feedback on this. Thanks

charisad commented 2 years ago

The tool supports 1014 and VBS but I don't think I have ever wanted to convert between formats and encodings before - you could use the library to create such a converter if you wanted.

Otherwise you could use mci_ipm_to_csv --in-encoding ascii --no1014blocking to get the file to CSV then mci_csv_to_ipm --out-encoding cp500 to generate it in the new format. Let me know how you go.

Thank you Delosa, this worked perfectly, Thanks very much

adelosa commented 2 years ago

Another issue reminded me there are command line tools to do a direct conversion of IPM files:

Although they don't support changing the blocking.. will need to add that.