ASCII to EBCDIC conversion including (decimal packed comp-3 conversion) for a float value using python 2.7

33 Views Asked by At

I need help with converting my file from ASCII to EBCDIC before sending it to the vendor. Has anyone implemented this kind of solution using python 2.7 in their projects?

My File row data looks like the below:

 -----------------------------------
 12345ABC6789 000006.12DEF
 -----------------------------------

It is a fixed fixed-width file, and I can break it like this.

------------------------------------
 Field   Data          Length
 ------------------------------------------
 Field1 '12345'        05
 Field2 'ABC'          03
 Field3 '6789'         04
 Field4 ' 000006.12'   10
 Field5 'DEF'          03
 ------------------------------------

My Target EBCDIC layout from vendor looks like this.

 ------------------------------------------------------
 Level & Cobol Name   Picture Clause       Start   End
 ------------------------------------------------------
 Field1               X(05)                 1       5
 Field2               X(03)                 6       8
 Field3               X(04)                 9       12
 Field4               S9(06)V99 COMP-3      13      17
 Field5               X(03)                 18      20
 ------------------------------------------------------

Entire row should be converted to EBCDIC format and while doing that need to make sure field4 is converted.

Thanks in advance.

I tried a couple of things in python but not getting the expected results.

0

There are 0 best solutions below