how to read an excel file and load the only selected columns

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: how to read an excel file and load the only selected col

Postby NicC » Fri Jun 29, 2012 8:32 pm

Do it with sort - easy. The difficult part may be in omitting the headers but that is probably an OMIT when you do a subsring search in the first few bytes looking for 'CURRENT'.

Unless when you need a new output file when you get a new header? How many columns are there? This is important as you can only parse 100 columns. If you have more than `00 then you need to parse the first 99 then parse the remaining columns into 1 field which can be parsed in a second pass of the data. At least, I think that is how you go about it. A Rexx program would do this in next to no time.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Global moderator
Posts: 3026
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: how to read an excel file and load the only selected col

Postby dick scherrer » Fri Jun 29, 2012 9:51 pm


If you have more than 100 fields or the file has millions of records, i would use neither the sort nor REXX. There is no good reason to pass the file multiple times. There is also no good reason to inflict the resource drain of REXX reading/writing lots of records when copying the file. (Unless your family gets to bill for resource usage).

The COBOL code to do what you want is quite basic and might only take a cpouple of hours - and most of that would be defining the indivisual gields and coding the UNSTRING to copy the data from the entire-record field to the individual fields.
Hope this helps,
User avatar
dick scherrer
Global moderator
Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol


  • Related topics
    Last post