How To Read Cobol Data Files

How To Read Cobol Data Files Average ratng: 3,2/5 5664 reviews

'Batista, Facundo' wrote in messagenews:ma.@pyth on.org. 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, fileswritten 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 COBOLfile and write a CSV one (easily readable from python).What's the OS for the two languages?

This function is used to get character data. In COBOL, this is called display data. It will be in EBCDIC if our files originated on a mainframe. This function is used to get packed decimal data. In COBOL, this is called 'comp-3' data. COBOL File Read - Learn COBOL in simple and easy steps with examples. Picture Clause, Data Types, Value Clause, Set Verb, Data Type Justifications,.

Virtual dj windows 7. COBOL from mainframeto X86ish is very different from some flavor of Windows or UnixCOBOL.Also, are we talking fixed or variable length records? And ifvariable, how are they structured?In either case, I think the struct module (under String Services)is what you're looking for.John RothThank you all!Facundo BatistaDesarrollo de Red(54 11) 5130-4643Cel: 15 5132 0132. 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 writtenwith 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 COBOLfile and write a CSV one (easily readable from python).Thank you all!Facundo BatistaDesarrollo de Red(54 11) 5130-4643Cel: 15 5132 0132i'm going to watch this thread with interest. A couple of weeks ago, iasked about python to legacy mvs particularly for DB2 and Adabas access.i got zero responses which suggested to me that no tools or modulesare in wide use.i think you are undertaking a simpler problem generally. If all yourrecords are text it should be fairly straightforward. If not, you'llneed to figure out how to map COBOL data representations into python.i seem to remember COMP-3, COMP-5 and packed decimal formats, amongothers.

What they mean, i dont't know, but generally various floatingand fixed point formats.you also need to handle REDEFINES which is used to produce a c-unionsort of arrangement, where multiple formats can be used to access thesame 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. Shouldbe feasible, in light of COBOL's very limited syntax.ah, COBOL fun. All us old guys are reflecting on how glad we are weleft 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. 'asdf sdf' wrote in messagenews:VY.@newssvr29.news.prodigy. 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, fileswritten 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 COBOLfile and write a CSV one (easily readable from python).Thank you all!Facundo BatistaDesarrollo de Red(54 11) 5130-4643Cel: 15 5132 0132i'm going to watch this thread with interest.

A couple of weeks ago, iasked about python to legacy mvs particularly for DB2 and Adabas access.i got zero responses which suggested to me that no tools or modulesare in wide use.I missed seeing it, somehow, but you're also right: I don't knowof any tools either.i think you are undertaking a simpler problem generally. If all yourrecords are text it should be fairly straightforward.

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 writtenwith 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 COBOLfile and write a CSV one (easily readable from python).Thank you all!Facundo BatistaDesarrollo de Red(54 11) 5130-4643Cel: 15 5132 0132I wrote an ETL system in python for a client to convert from MicrofocusCOBOL to DB2. Steve Williams wrote:I wrote an ETL system in python for a client to convert from MicrofocusCOBOL to DB2. Here are some of the problems I saw:1) COBOL has a very rich set of datatypes defined by the PICTURE clauseThat is, I took the original COBOL 01 level definition andconverted it to a list with definition parameters name, type,length, decimal point, etc. To make it easy for Python andto add some stuff to make DB2 happy (convert to title case.)Steve,I've been looking for ideas on getting at DB2 and Adabas from Python.You might have some thoughts.Is it feasible to go to directly to MVS/DB2/Adabas from Python on Unixor Win?Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2linking or replication to reach DB2/MVS?Other ideas? Maybe 3270 emulation with screen scraping?

How abouttelnet 3270? (Hundreds years of ago, I could dial into a command lineMVS environment.)I don't mean to hijack the thread. I think this is related and might behelpful to unfortunates to have to interoperate with legacy systems. Asdf sdf wrote: Steve Williams wrote:I wrote an ETL system in python for a client to convert fromMicrofocus COBOL to DB2. Here are some of the problems I saw:1) COBOL has a very rich set of datatypes defined by the PICTURE clauseThat is, I took the original COBOL 01 level definition andconverted it to a list with definition parameters name, type,length, decimal point, etc.

To make it easy for Python andto add some stuff to make DB2 happy (convert to title case.)Steve,I've been looking for ideas on getting at DB2 and Adabas from Python.You might have some thoughts.Is it feasible to go to directly to MVS/DB2/Adabas from Python on Unixor Win?Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2linking or replication to reach DB2/MVS?Other ideas? Maybe 3270 emulation with screen scraping? How abouttelnet 3270? (Hundreds years of ago, I could dial into a command lineMVS environment.)I don't mean to hijack the thread. I think this is related and might behelpful to unfortunates to have to interoperate with legacy systems.Well, the application processed a lot of data on a nightly basis. Itused FTP to connect to the COBOL machine (an AIX box) and FTP callbacksto sequentially read the files and convert the the data. There are twoa bugs in the Python FTP module that surface if the file size is largerthan 2 gig, but they're easily fixed.I developed this application on Windows, initially targeting a test DB2database on Windows and then moving the DB2 database to AIX and postingwith ODBC over the network from Windows.In the full production environment I moved the Pythonapplication to AIX.

The moves were straightforward-Python was platformindependent for my purposes.Initially I used ODBC or the API to post the data to DB2, butthat turned out to be slow. To get the speed I needed, I just wrotethe converted data to a CSV flat file and passed the file to theDB2 loader utilities. No matter how good your code is, you'll neveroutperform the database utilities.I've never used replication or linking. I know nothing about DB2 onMVS.

In general, my experience with DB2 on networks (admittedly Unixand Windows boxes) tells me accessing DB2 on MVS over a network wouldnot be a problem. I know nothing about ADABAS.Python will certainly do TELNET and screen scraping, but life is short.Other than the overall success of the project (I've been told successfuldata warehouse projects are rare) the major benefit of using Python wasthe ability to try new concepts quickly. With python you haveenormous flexibility, as opposed to compiled languages (COBOL, C, etc)or third party ETL utilities.As an example, my application converted accounting data ona nightly basis. With no advance warning, the Accounting departmentconverted to another package. The python code to extract and loadthe data from the new system was written and in production in 2 days. Steve Williams wrote in message news. Asdf sdf wrote: Is it feasible to go to directly to MVS/DB2/Adabas from Python on Unixor Win?At least for DB2 this shouldn't be a problem - but would typicallyinvolve a separate product - called 'DB2 Connect'.

Shouldn't be cheapor require any MVS components:Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2linking or replication to reach DB2/MVS?No, DB2 Connect should give you odbc, jdbc, cli, etc protocolsdirectly to mvs. You can go through another db2 database, but that'sprobably extra work & complexity.Other than the overall success of the project (I've been told successfuldata warehouse projects are rare) the major benefit of using Python wasthe ability to try new concepts quickly. With python you haveenormous flexibility, as opposed to compiled languages (COBOL, C, etc)or third party ETL utilities.Nice case study.

I've been building ETL systems for twelve years andam on my second python etl project right now. Python has proveditself the best option - there's nothing like adaptability when you'vegot a dozen system interfaces to maintain! And its quick learningcurve has meant that bringing others up to speed has been a snap.Most of my communication with db2 is just over the command line (viapopen2.Popen3) which is the only way to issue commands such as load,export, force application, list application, etc.

However, quite afew of my summaries are run this way as well (typically mass inserts)and aside from the primitive error codes, it works fine. There's alsoat least one db2 python package (PyDB2). Here's a link to thepackage:and here's a link to a tutorial for it:I'm not using it yet, though a coworker just installed and startedusing a python db2 module - I assume that it is this one.And as far as reading files written in COBOL, here's a few thoughts:1. Don't make python read all the COBOL data types, instead make theCOBOL program write out a plain ascii record. Writing to afixed-length ascii record is very simple (if a little tedious to parseon the other side).2. If you can't modify the COBOL output.then you could consider acommercial (perhaps with a free trial license) product that alreadyprovides COBOL 'copybook' interpretation. There are quite a few ofthese, though the least expensive ones I'm aware of are SyncSort, DataJunction, and perhaps Compuware's FileAid.

Don't think any have aregular license for less than $1500.3. If you have to read non-character cobol files, then I'd try tojust keep the number of options down to a reasonable number: you mayonly need to support a few formats - such as zoned & packed decimal(comp-3) for instance. Variable length files, float, comp-4, isam,etc aren't that common. Redefines are often used in conjuction withrecord types, and this can be sometimes simplified by just splittingthe file into multiple separate files by record type.

And all theformatting in the picture clause can be easily handled in the programthat reads the files (implied decimal places, signs, etc are all verysimple).buck.