Joined: 01 Nov 2019 Posts: 1 Location: United States of America
I have requirement wherein I have to exclude the first and last column of a pipe-delimited VB file. The position of the first and last column is not fixed, it can vary from one record to the other. The file is RECFM=VB and LRECL=2000
I thought of using the below SORT card to exclude the first and last column:
OUTREC PARSE=(%=(ENDBEFR=C'|'),
%01=(ENDBEFR=C'|',FIXLEN=10),
%72=(ENDBEFR=C'|',FIXLEN=20),
%=(FIXLEN=35)),
BUILD=(1,4, * RDW
%01 and so on)
But the problem with this is that I have to give FIXLEN to each field I declare in the PARSE which I don't want to as it will add trailing spaces towards the end of each column. As each column can contain spaces in between also, so removing only the trailing spaces through SQZ wouldn't be an option.
The sample input data is below:
First_Col|Second_Col|..............and so on|Last_Col
0123456789|Test Rec1|..............and so on|9876543210
9876543210|Test Record 2|..............and so on|0123456789
623452132333|T e s t R e c 3|..............and so on|865685611
So is there any way in SORT, SPLICE or ICETOOL to remove just the first and last column and then extract all the other fields in between without touching the data in any of the intermediate columns?
OUTREC PARSE=(%=(ENDBEFR=C'|'),
%01=(ENDBEFR=C'|',FIXLEN=10),
%72=(ENDBEFR=C'|',FIXLEN=20),
%=(FIXLEN=35)),
BUILD=(1,4, * RDW
%01 and so on) . . .
But the problem with this is that I have to give FIXLEN to each field I declare in the PARSE which I don't want to as it will add trailing spaces towards the end of each column. As each column can contain spaces in between also, so removing only the trailing spaces through SQZ wouldn't be an option.
I would assume that normally "spaces between" must be all converted to a single space each.
If so then use the Option VL after each %-variable field:
Code:
BUILD=(. . . %1,SQZ=(VL,MID=C' '), . . .
Would make sense also to replace ENDBEFR= parameter with ENDAT=, to simplify the final BUILD= list