问题
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.
回答1:
Options
Some options
- Convert the file to a Text file on the mainframe (sort or eastrieve will both do this)
- If it is a once off the Fileaid/File master can convert the file to Text on the mainframe
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.
- The JRecord lets you read a Cobol Copybook in Java
- JRecord has a COBOL Copy utility will let you do a Cobol to cobol copy. If there is only one Record type you can
- Copy the EBCDIC Copybook to the equivalent Ascii copybook (ext fields are converted, binary fields are left unchanged). This is usefull if converting a Mainframe Cobol file for use in a Windows / Linux Cobol system
- Copy a EBCDIC Binary Copybook to an Ascii Text copybook
- The Stingray project provides access to cobol files in python
CobolTCsv
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
- In/DTAR020.bin is the Input Cobol data file
- Out/o_DTAR020_space.csv is the output Csv file
- **DTAR020.cbl ** is the Cobol Copybook
- Fixed_Length idicates it a fixed length File (FB on the Mainframe)
RecordEditor
- To edit the file see How do you edit a Binary Mainframe file in the RecordEditor using a Cobol Copybook (pt1)
- To generate JRecord Code see How do you generate java~jrecord code for a Cobol copybook
来源:https://stackoverflow.com/questions/56437665/ebcdic-to-ascii-conversions