1

I have txt file exported from mainframe, which contains the packed decimal data, looks like junk data. I want convert it to readable format using python script.

for ex. convert this ��% to 5420

SKP
  • 151
  • 16
  • 1
    There are infinite ways to "pack decimal data". Which mainframe is this? Which software on it? Can you show us a hex dump of the pertinent parts of the file instead of (likely misinterpreted) text characters. – AKX Apr 27 '20 at 07:15
  • @AKX, PIC S9(9)V Usage comp-3 is used and sample hex value: 03346 – SKP Apr 29 '20 at 06:50
  • Welp, looks like it's a form of Binary Coded Decimal. You'll have to write a decoder for the bytes (_not_ the text characters you've pasted!) - the spec seems outlined here: http://www.3480-3590-data-conversion.com/article-packed-fields.html – AKX Apr 29 '20 at 07:03
  • sorry, its PIC S9(9)V Usage comp-3 is used and sample hex value: 03346(1st row digit) 2345C (2nd row digit) – SKP Apr 29 '20 at 07:09
  • Well, https://stackoverflow.com/questions/29232656/decoding-comp-3-packed-fields-in-an-ascii-file-in-python and https://gist.github.com/zorchenhimer/fd4d4208312d4175d106 may help you out. Good luck! – AKX Apr 29 '20 at 07:15
  • @AKX, Thanks for the reply, but it is giving the incorrect readable output. – SKP Apr 30 '20 at 12:22

0 Answers0