Reputation:
I have mainframe file in EBCDIC format and I want to convert those files into ASCII format.
I have tried converting EBCDIC to ASCII using python 2.6 but there are many issues in that like compression field didn't get converted and records count gets increased.
Is there any way to convert EBCDIC files having compressed fields to ASCII format.
Upvotes: 1
Views: 11508
Reputation: 31
If you already have the file downloaded you can convert it easily from EBCDIC to ASCII in a Linux or MacOS machine by using the command line.
To accomplish that you need to use the dd
command.
Here a quick overview of some parameters it uses:
dd [bs=size] [cbs=size] [conv=conversion] [count=n] [ibs=size] [if=file] [imsg=string] [iseek=n] [obs=s] [of=file] [omsg=string] [seek=n] [skip=n]
There are more parameters that those above, to check all available just do the command: man dd
, it will show all other available parameters and the explanation of each one.
In your case you should start with:
dd conv=ascii if=EBCDIC_file.txt of=ASCII_file.txt
where EBCDIC_file.txt is the filename of your input EBCDIC file and ASCII_file.txt will be the file created as output with all bytes converted from EBCDIC to ASCII.
Likewise you can do the reverse by using conv=ebcdic
to convert a file from ASCII to EBCDIC.
Here's the man page for dd
on the web: https://www.man7.org/linux/man-pages/man1/dd.1.html
When you mention compressed in your file, do you mean the whole file comes compressed from the mainframe? Probably it came TERSED (by using terse utility on mainframe). If this is the case, there is a public version of terse that runs on DOS, Linux, MacOS, AIX and others. It is available on cbtape site: http://www.cbttape.org/ftp/cbt/CBT892.zip
Upvotes: 2
Reputation: 10543
Some options
If it is a once off the RecordEditor should be able to edit the file with a Cobol Copybook. It can also generate JRecord code to read the file.
If there is only one Record-Type in the file, CobolToCsv can use the Cobol Copybook to convert the file to a CSV.
For Example to convert a Cobol Data File to Csv (single record type) using CobolToCsv :
java -jar ../lib/Cobol2Csv.jar -I In/DTAR020.bin -O Out/o_DTAR020_space.csv ^
-C DTAR020.cbl ^
-Q DoubleQuote -FS Fixed_Length ^
-IC CP037 -Delimiter ,
Where
Upvotes: 1