Fixed Length Cobol Records (.GCUS) - Converting to XML or CSV

585 Views Asked by At

So I'm attempting to work with files that are created as COBOL fixed length records. I was given the raw data files (.GCUS file extension) and a "file layout" document that has specifications which include a table with the following columns "Position, Picture, Type, Description" (it has two sections, a "header" record and a "Detail Record A".

I have never worked with any COBOL file types before and I'm trying to find a way to parse and read these files for use in an internal application and ideally I need them to be re-exported in either CSV or XML so I can import them in the application we're building.

So far the only software I've found that can read these files is this one: https://www.fundmanagersoftware.com/

But I haven't found the option within it to actually export to a CSV or XML.

Any suggestions would be greatly appreciated.

2

There are 2 best solutions below

4
On

This open source project should do the trick

http://cb2xml.sourceforge.net/

Given a COBOL copybook it generates a java program to convert the data.

0
On

If you have documentation of the fields in each type of record, you can put a comma between each field and voila you have a CSV.

You already have the starting offset (and implied length) for each. The picture clause along with the type should give the format.

If there are any binary or packed decimal fields (COMP or COMP-3) you may have to convert the byte values to numerics. Information about this should be available elsewhere on the internet, in COBOL primers, and here on SO. Search for "COBOL PIC CLAUSE" for relevant information such as at http://www.3480-3590-data-conversion.com/article-reading-cobol-layouts-1.html

If you want more specific help, post sample data and file layout details.