Page 3 of 3

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 11:26 pm
by AKDEARAGON
my input is like this:
.10/11/2011.12/15/2011
..5/15/2011
.12/5/2011.3/21/2011

On second occurance I don't have the first date. how do I check for that and leave a value on the output? I want out put to be:
2011101120111215
20110515
2011120520110321

The missing date can be blank or zeros.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 11:48 pm
by skolusu
AKDEARAGON wrote:my input is like this:
.10/11/2011.12/15/2011
..5/15/2011
.12/5/2011.3/21/2011

On second occurance I don't have the first date. how do I check for that and leave a value on the output? I want out put to be:
2011101120111215
20110515
2011120520110321

The missing date can be blank or zeros.


Did you see my last post? Fyi
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
10/11/2011 12/15/2011                                                 
.5/15/2011                                                           
.12/5/2011 3/21/2011                                                 
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC PARSE=(%01=(ENDBEFR=C'/',FIXLEN=02),                         
               %02=(ENDBEFR=C'/',FIXLEN=02),                         
               %03=(ENDBEFR=X'05',FIXLEN=04),                         
               %04=(ENDBEFR=C'/',FIXLEN=02),                         
               %05=(ENDBEFR=C'/',FIXLEN=02),                         
               %06=(ENDBEFR=X'05',FIXLEN=04)),                       
  BUILD=(%03,UFF,EDIT=(TTTT),%01,UFF,EDIT=(TT),%02,UFF,EDIT=(TT),C'|',
         %06,UFF,EDIT=(TTTT),%04,UFF,EDIT=(TT),%05,UFF,EDIT=(TT))     
//*                                                                   


will produce
20111011|20111215
20110515|00000000
20110105|20110321

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 11:54 pm
by AKDEARAGON
I didn't notice that my data slide over for expected results, It should of been :

2011101120111215
20110515
2011120520110321


I do not have space between the two columns of dates to put any character.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Thu Oct 13, 2011 11:56 pm
by AKDEARAGON
on the input each field is seperated by x'05' or so when it gets to the date and it starts to look for the / but find just then next x'05' how does it know to skip that date but leave a position for it on the output and go to the second date?

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Fri Oct 14, 2011 12:05 am
by BillyBoyo
AKDEARAGON wrote:I didn't notice that my data slide over for expected results, It should of been :

2011101120111215
        20110515
2011120520110321


I do not have space between the two columns of dates to put any character.


You have to use the Code tags to preserve spacing. It is the Code button over the input area. Highlight the text you have formatted, then use the Preview button to check it. Then Submit when you are happy with how it looks.

The spaces in the ordinary text are "proportional" and leading space is swallowed without being displayed, so you got your slippage.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Fri Oct 14, 2011 1:20 am
by skolusu
AKDEARAGON wrote:I do not have space between the two columns of dates to put any character.


Sigh*. I did not have a space. The space you see is actually x'05'. In edit mode it looks like it is a space and in browse mode it is shown as .

if your dates are indeed separated by tab x'05' then the JCL I posted will work.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Fri Oct 14, 2011 2:33 am
by AKDEARAGON
My data comes back as if the missing first date isn't there it doesn't leave space for it on the output. I'll list out better example:

Input from .csv file
X.X..8/23/2010.10.5/20/2011.7
X.X..8/24/2010.10.5/26/2011.7
X.X..4/28/2011.1.4/29/2011.7


expected output:
XX               20100823102011052007
XX               20100824102011052607
XX               20110428012011042907


what i'm getting is:

XX201008232011102007
XX201008242011102607
XX201104282011012907


i'm using your type of code but as you can see it isn't handling the missing first date. It will not always be missing.

Re: csv 2 fixed with non consistant amount fileds

PostPosted: Fri Oct 14, 2011 5:03 am
by skolusu
AKDEARAGON,

As Bill explained earlier, you need to use code tags to be able to see how the spacing is retained. Frank added the code tags for you. In future make sure to enclose the data/jcl in code tags.

Anyway since your input has both missing dates as well as left justified dates you need to do double parsing.

1. parse and get the values and put the date fields at the end of the file in fixed positions. I assumed input is FB 80 byes , so I added the date fields at the end at pos 81,91,101

2. Now parse again the date fields specifying the positions looking for separators and build the entire record as needed.



//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
X.X..8/23/2010.10.5/20/2011.7                                 
X.X..8/24/2010.10.5/26/2011.7                                 
X.X..4/28/2011.1.4/29/2011.7                                   
X.X.12/1/2012.10/5/2011.2.11/9/2011.8                         
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=INIT,                                       
        PARSE=(%01=(ENDBEFR=X'05',FIXLEN=1),    $ VALUE-1         
               %02=(ENDBEFR=X'05',FIXLEN=1),    $ VALUE-2         
               %03=(ENDBEFR=X'05',FIXLEN=10),   $ DATE-1         
               %04=(ENDBEFR=X'05',FIXLEN=10),   $ DATE-2         
               %05=(ENDBEFR=X'05',FIXLEN=02),   $ VALUE-3         
               %06=(ENDBEFR=X'05',FIXLEN=10),   $ DATE-3         
               %07=(ENDBEFR=X'05',FIXLEN=01)),  $ VALUE-4         
  OVERLAY=(81:%03,%04,%06)),                                     
                                                                 
  IFTHEN=(WHEN=INIT,                                             
  PARSE=(%08=(ABSPOS=81,ENDBEFR=C'/',ENDBEFR=C' ',FIXLEN=2),     
         %09=(ENDBEFR=C'/',ENDBEFR=C' ',FIXLEN=2),               
         %10=(FIXLEN=4),                                         
         %11=(ABSPOS=91,ENDBEFR=C'/',ENDBEFR=C' ',FIXLEN=2),     
         %12=(ENDBEFR=C'/',ENDBEFR=C' ',FIXLEN=2),               
         %13=(FIXLEN=4),                                         
         %14=(ABSPOS=101,ENDBEFR=C'/',ENDBEFR=C' ',FIXLEN=2),     
         %15=(ENDBEFR=C'/',FIXLEN=2),                             
         %16=(FIXLEN=4)),                                         
  BUILD=(%01,                            $ VALUE-1         
         %02,                            $ VALUE-2         
         %10,UFF,EDIT=(TTTT),            $ DATE-1-CCYY     
         %08,UFF,EDIT=(TT),              $ DATE-1-MM       
         %09,UFF,EDIT=(TT),              $ DATE-1-DD       
                                                           
         %13,UFF,EDIT=(TTTT),            $ DATE-2-CCYY     
         %11,UFF,EDIT=(TT),              $ DATE-2-MM       
         %12,UFF,EDIT=(TT),              $ DATE-2-DD       
                                                           
         %05,UFF,EDIT=(TT),              $ VALUE-3         
                                                           
         %16,UFF,EDIT=(TTTT),            $ DATE-3-CCYY     
         %14,UFF,EDIT=(TT),              $ DATE-3-MM       
         %15,UFF,EDIT=(TT),              $ DATE-3-DD       
                                                           
         %07,UFF,EDIT=(TT)))             $ VALUE-4         
                                                           
//*