A Python library to convert COBOL ebcdic file to CSV format based on copybook
Project description
pycobol2csv
pycobol2csv is a Python library to convert COBOL ebcdic file to CSV format. The package is built to cater for advanced features in COBOL copybooks such as OCCURES x TIMES, BINARY, COMP.
The CSV file is RDBMS friendly and all headers are ready to be used as database column names. CSV conversion is controlled by config file in csv_config.json
Added more enhancements for the outdated REDEFINE and PIC syntax for a new client
Install the python module:
pip install pycobol2csv
To use the module:
from pycobol2csv import convert_cobol_file, decode_copybook_file
row_length, cobol_struc = decode_copybook_file(copybook_file)
convert_cobol_file(copybook_file, data_file, output_file, config_file, codepage, debug=False)
- copybook_file: copybook filename
- data_file: data filename
- output_file: output csv filename
- config_file: csv configuration filename, refer to csv_config.json
- codepage: codepage for edibic, refer to https://docs.python.org/3.7/library/codecs.html#standard-encodings for details
- debug: enable for more debug information, default is OFF
test
2 sets of test data have been created from scratch. Each set includes a copybook and an EBCDIC data file.
To test:
python convert_cobol_test_main.py --copybook [COPYBOOK_FILE] --data [DATA_FILE] --output [CSV_FILE]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pycobol2csv-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2fe5e71b2549702e9b12a307ddf30428ee9bbc43b6c443046aebe072e38be75 |
|
MD5 | 4e45676ef55e2fc25e2e84947dd674ee |
|
BLAKE2b-256 | 90c40943a3d1ca19c9bbf9db77915b6f4d7351d5fabd550e7706d6743e7a9b35 |