How to read files written with COBOL

John Roth newsgroups at jhrothjr.com
Mon May 10 18:47:38 EDT 2004


"asdf sdf" <asdf at asdf.com> wrote in message
news:VYSnc.46990$v46.35205 at newssvr29.news.prodigy.com...
> Batista, Facundo wrote:
> > People:
> >
> > I'm trying to convert my father from using COBOL to Python, :)
> >
> > One difficult thing we stuck into is how to read, from python, files
written
> > with COBOL.
> >
> > Do you know a module that allows me to do that?
> >
> > It should avoid us the work to write a COBOL program that open the COBOL
> > file and write a CSV one (easily readable from python).
> >
> > Thank you all!
> >
> > Facundo Batista
> > Desarrollo de Red
> > fbatista at unifon.com.ar
> > (54 11) 5130-4643
> > Cel: 15 5132 0132
> >
> >
> >
> i'm going to watch this thread with interest.  a couple of weeks ago, i
> asked about python to legacy mvs particularly for DB2 and Adabas access.
>   i got zero responses which suggested to me that no tools or modules
> are in wide use.

I missed seeing it, somehow, but you're also right: I don't know
of any tools either.

> i think you are undertaking a simpler problem generally.  if all your
> records are text it should be fairly straightforward.  if not, you'll
> need to figure out how to map COBOL data representations into python.

In other words, take the 01s under the FD and create an object
that would expose all the converted data elements for the record?
Could be a somewhat interesting project, and it shouldn't be all
that hard since data descriptions are a fairly limited syntax.

> you also need to handle REDEFINES which is used to produce a c-union
> sort of arrangement, where multiple formats can be used to access the
> same record.

Redefines in implicit - it's just multiple level 01s under the same FD.

> 88-Levels are a similar problem.

Aren't an issue. 88s are basically an isXXX type function call. That's not
how they're implemented, but that's the basic semantics.

> after Y2K, a lot of COBOL files contain some non-obvious date handling,
> which could involve bit manipulation.
>
> if you learn of any sorts of tools at all, please post them back here.
> python screen scrapers, python compatible database drivers, anything at
all.
>
> interesting project idea:  a COBOL to python _code_ converter.  should
> be feasible, in light of COBOL's very limited syntax.
>
> ah, COBOL fun.  all us old guys are reflecting on how glad we are we
> left it behind.

Ain't that the truth!

John Roth





More information about the Python-list mailing list