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 fb******@unifon .com.ar
(54 11) 5130-4643
Cel: 15 5132 0132 7 14887
"Batista, Facundo" <FB******@uniFO N.com.ar> wrote in message
news:ma******** *************** *************** @python.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, 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).
What's the OS for the two languages? COBOL from mainframe
to X86ish is very different from some flavor of Windows or Unix
COBOL.
Also, are we talking fixed or variable length records? And if
variable, how are they structured?
In either case, I think the struct module (under String Services)
is what you're looking for.
John Roth Thank you all!
Facundo Batista Desarrollo de Red fb******@unifon .com.ar (54 11) 5130-4643 Cel: 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 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 fb******@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.
"asdf sdf" <as**@asdf.co m> wrote in message
news:VY******** ***********@new ssvr29.news.pro digy.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 fb******@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
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 fb******@unifon .com.ar (54 11) 5130-4643 Cel: 15 5132 0132
I wrote an ETL system in python for a client to convert from Microfocus
COBOL to DB2. Here are some of the problems I saw:
1) COBOL has a very rich set of datatypes defined by the PICTURE clause
character
unsigned integer
zoned signed integer
integer trailing sign separate
integer leading sign separate
packed signed decimal
packed unsigned decimal
floating point
with the usual COBOL zoo of implied decimal points and scaling
Not to mention COBOL allowing formatted numeric data to be
used as source fields in arithmetic operations.
In my application, each of these types was converted by a
parameter-driven function.
That is, I took the original COBOL 01 level definition and
converted it to a list with definition parameters name, type,
length, decimal point, etc. to make it easy for Python and
to add some stuff to make DB2 happy (convert to title case. . .)
I doubt if you can easily write a parser for the COBOL PICTURE
clause and for most cases it would be a waste of time. I just
converted the definition by using 'replacing all occurences' in
a text processor.
I had the most problem with Microfocus unsigned decimal, as
I'd never seen it before.
2) Reading fixed and variable length records wasn't much of a problem
Reading Microfocus keyed sequential data with embedded indexes
took some bit-level coding.
3) None of this would be remotely attractive to a COBOL programmer.
Converting the data to CSV, however, might get his attention
as it's pretty easy in Python and not much fun in COBOL.
I you want to sell dad, talk about text and string processing
in Python.
Steve Williams wrote: I wrote an ETL system in python for a client to convert from Microfocus COBOL to DB2. Here are some of the problems I saw:
1) COBOL has a very rich set of datatypes defined by the PICTURE clause
<...snipping various items...>
That is, I took the original COBOL 01 level definition and converted it to a list with definition parameters name, type, length, decimal point, etc. to make it easy for Python and to 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 Unix
or Win?
Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2
linking or replication to reach DB2/MVS?
Other ideas? Maybe 3270 emulation with screen scraping? How about
telnet 3270? (Hundreds years of ago, I could dial into a command line
MVS environment.)
I don't mean to hijack the thread. I think this is related and might be
helpful 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 from Microfocus COBOL to DB2. Here are some of the problems I saw:
1) COBOL has a very rich set of datatypes defined by the PICTURE clause
<...snipping various items...>
That is, I took the original COBOL 01 level definition and converted it to a list with definition parameters name, type, length, decimal point, etc. to make it easy for Python and to 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 Unix or Win?
Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2 linking or replication to reach DB2/MVS?
Other ideas? Maybe 3270 emulation with screen scraping? How about telnet 3270? (Hundreds years of ago, I could dial into a command line MVS environment.)
I don't mean to hijack the thread. I think this is related and might be helpful to unfortunates to have to interoperate with legacy systems.
Well, the application processed a lot of data on a nightly basis. It
used FTP to connect to the COBOL machine (an AIX box) and FTP callbacks
to sequentially read the files and convert the the data. There are two
a bugs in the Python FTP module that surface if the file size is larger
than 2 gig, but they're easily fixed.
I developed this application on Windows, initially targeting a test DB2
database on Windows and then moving the DB2 database to AIX and posting
with ODBC over the network from Windows.
In the full production environment I moved the Python
application to AIX. The moves were straightforward--Python was platform
independent for my purposes.
Initially I used ODBC or the API to post the data to DB2, but
that turned out to be slow. To get the speed I needed, I just wrote
the converted data to a CSV flat file and passed the file to the
DB2 loader utilities. No matter how good your code is, you'll never
outperform the database utilities.
I've never used replication or linking. I know nothing about DB2 on
MVS. In general, my experience with DB2 on networks (admittedly Unix
and Windows boxes) tells me accessing DB2 on MVS over a network would
not 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 successful
data warehouse projects are rare) the major benefit of using Python was
the ability to try new concepts quickly. With python you have
enormous flexibility, as opposed to compiled languages (COBOL, C, etc)
or third party ETL utilities.
As an example, my application converted accounting data on
a nightly basis. With no advance warning, the Accounting department
converted to another package. The python code to extract and load
the data from the new system was written and in production in 2 days.
Steve Williams <st***********@ wwc.com> wrote in message news:<nJ******* **************@ nwrddc01.gnilin k.net>... asdf sdf wrote: Is it feasible to go to directly to MVS/DB2/Adabas from Python on Unix or Win?
At least for DB2 this shouldn't be a problem - but would typically
involve a separate product - called "DB2 Connect". Shouldn't be cheap
or require any MVS components: http://www-306.ibm.com/software/data/db2/db2connect/
Is it more realistic to hit DB2 on AIX or Linux and use some kind of DB2 linking or replication to reach DB2/MVS?
No, DB2 Connect should give you odbc, jdbc, cli, etc protocols
directly to mvs. You can go through another db2 database, but that's
probably extra work & complexity.
Other than the overall success of the project (I've been told successful data warehouse projects are rare) the major benefit of using Python was the ability to try new concepts quickly. With python you have enormous 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 and
am on my second python etl project right now. Python has proved
itself the best option - there's nothing like adaptability when you've
got a dozen system interfaces to maintain! And its quick learning
curve has meant that bringing others up to speed has been a snap.
Most of my communication with db2 is just over the command line (via
popen2.Popen3) which is the only way to issue commands such as load,
export, force application, list application, etc. However, quite a
few of my summaries are run this way as well (typically mass inserts)
and aside from the primitive error codes, it works fine. There's also
at least one db2 python package (PyDB2). Here's a link to the
package: http://sourceforge.net/projects/pydb2/
and here's a link to a tutorial for it: https://www6.software.ibm.com/reg/de...91&S_CMP=DB2DD
I'm not using it yet, though a coworker just installed and started
using 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 the
COBOL program write out a plain ascii record. Writing to a
fixed-length ascii record is very simple (if a little tedious to parse
on the other side).
2. if you can't modify the COBOL output...then you could consider a
commercial (perhaps with a free trial license) product that already
provides COBOL 'copybook' interpretation. There are quite a few of
these, though the least expensive ones I'm aware of are SyncSort, Data
Junction, and perhaps Compuware's FileAid. Don't think any have a
regular license for less than $1500.
3. if you have to read non-character cobol files, then I'd try to
just keep the number of options down to a reasonable number: you may
only 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 with
record types, and this can be sometimes simplified by just splitting
the file into multiple separate files by record type. And all the
formatting in the picture clause can be easily handled in the program
that reads the files (implied decimal places, signs, etc are all very
simple).
buck This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Cameron |
last post by:
Hi I'm developing a program and the client is worried about future
reuse of the code. Say 5, 10, 15 years down the road. This will be a
major factor in selecting the development language. Any comments on
past experience, research articles, comments on the matter would be
much appreciated. I suspect something like C would be the best based
on comments I received from the VB news group.
Thanks for the help in advance
James Cameron
|
by: none |
last post by:
Hi,
Any one know of some code to read cobol data files....
thanks
timb
|
by: Thomasb |
last post by:
Hi!
In our company we have a huge amount of COBOL sub-routines that are
called from other COBOL-programs.
Now we are looking for a method to call them from Windows/Web
applications.
One idea is to wrap the sub-routine call in a DB2 stored procedure and
call the procedure from our Web application.
|
by: EricJ |
last post by:
hi
i need to access cobol data files from .net, the files have no or .vix
extention (i think thats a acucobol or something like that) (/me has
completely no experience in cobol)
i heard that there should be an odbc connection for that.
Dous anyone have any ideas on how to do this??
--
|
by: singlal |
last post by:
Hi, my question was not getting any attention because it moved to 2nd
page; so posting it again. Sorry for any inconvenience but I need to
get it resolved fast. Need your help!
****************************************************************************************************
Original Question:
--------------------
Has anyone called a COBOL subroutine using COBOL CALL from a COBOL/DB2
| |
by: RyanS09 |
last post by:
Hello-
I am trying to write a snippet which will open a text file with an
integer on each line. I would like to read the last integer in the
file. I am currently using:
file = fopen("f.txt", "r+");
fseek(file, -2, SEEK_END);
fscanf(file, "%d", &c);
this works fine if the integer is only a single character. When I get
into larger numbers though (e.g. 502) it only reads in the 2. Is there
|
by: Tracks |
last post by:
I have old legacy code from vb5 where data was written to a file with a
variant declaration (this was actually a coding error?)...
in vb5 the code was:
Dim thisdata as integer
Dim thatdata
Dim someother as integer
thatdata = ubound( Array1 )
|
by: tickle |
last post by:
Need to convert this PL/SQL script to Dynamic SQL Method 2
* copybook - celg02u3.sql SIR 24265 *
* updates dt_deny for all rows in *
* the removal_eligibility_link table for all persons *
* in all stages associated with the victim who has *
* has had a specific legal status change *
EXEC SQL EXECUTE
|
by: Michiel Overtoom |
last post by:
Giveitawhril wrote...
No: Real programmers first eat a quiche and then return to their Pascal
programming.
C is alive and kicking. Every language has its place.
Plus, there exists implementations of Python written in Python itself;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |