How to read files written with COBOL

asdf sdf asdf at asdf.com
Mon May 10 18:01:25 EDT 2004


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 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.

i seem to remember COMP-3, COMP-5 and packed decimal formats, among 
others.  what they mean, i dont't know, but generally various floating 
and fixed point formats.

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.

88-Levels are a similar problem.

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.

it might be a good exercise for your dad, if he wants to retool himself, 
and he already knows all the data format stuff.





More information about the Python-list mailing list