IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Parsing using ICETOOL with quotes


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vina2010

New User


Joined: 06 Sep 2010
Posts: 19
Location: Bangalore

PostPosted: Wed Apr 25, 2012 3:51 am
Reply with quote

Hi

I have CSV data coming from an external system which mainly puts quotes for those data which has comma(,) within it mainly to mask the commas as separate data columns.

For e.g.
Data has a layout as below

Emp id, Name , address Line 1 , Address Line 2 , Country, Pincode

Sample data may contain

123123, Abc, " Address Line 1, Street1",Street2,Bangalore, 575007
1234,sdcdfer,Address 1,"Street 2, Karnataka",Mangalore, 534

So quotes occur dynamically based on occurrence of comma as data and not as a delimiter. Can I use any JCL utility to create a data in formatted fashion without quotes?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 25, 2012 4:26 am
Reply with quote

vina2010,

It would have been nice if you showed the desired output. I assumed that lengths for each field. You can change that the real lengths by changing the values in the FIXLEN field in the parse statement. Use the following DFSORT JCL
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
123123, ABC, " ADDRESS LINE 1, STREET1",STREET2,BANGALORE, 575007
1234,SDCDFER,ADDRESS 1,"STREET 2, KARNATAKA",MANGALORE, 534       
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=06),             $ EMP-ID   
               %02=(ENDBEFR=C',',FIXLEN=30),             $ NAME     
               %03=(ENDBEFR=C',',PAIR=QUOTE,FIXLEN=40),  $ ADDR LINE1
               %04=(ENDBEFR=C',',PAIR=QUOTE,FIXLEN=40),  $ ADDR LINE2
               %05=(ENDBEFR=C',',FIXLEN=20),             $ COUNTRY   
               %06=(FIXLEN=10)),                         $ PINCODE   
  BUILD=(%01,%02,%03,%04,%05,%06)                                   
                                                                     
  OUTREC FINDREP=(INOUT=(C'"',C''))                                 
//*                                                                 
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Mon Oct 01, 2012 5:28 pm
Reply with quote

Hi,

This is very useful!

We get data from an external partner, and they are not very consistent in the way the "pack" the data... Sometimes we get numeric fields wrapped in quotes - other times they are not.

The OUTREC FINDREP is ingenious, as it can get rid of those unwanted quotes! BUT when I ran some tests, it seems you need to be aware of it, because the columns are shifted, and thus the data may not be where you expected, anymore.

How can you cater for that? Using positions in BUILD of the INREC PARSE won't do the trick.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Mon Oct 01, 2012 5:52 pm
Reply with quote

Hmm, how about this:

Code:

  SORT FIELDS=COPY                                                   
  INREC PARSE=(%01=(ENDBEFR=C'#',PAIR=QUOTE,FIXLEN=06),  $ EMP-ID   
               %02=(ENDBEFR=C'#',PAIR=QUOTE,FIXLEN=30),  $ NAME     
               %03=(ENDBEFR=C'#',PAIR=QUOTE,FIXLEN=40),  $ ADDR LINE1
               %04=(ENDBEFR=C'#',PAIR=QUOTE,FIXLEN=40),  $ ADDR LINE2
               %05=(ENDBEFR=C'#',PAIR=QUOTE,FIXLEN=20),  $ COUNTRY   
               %06=(PAIR=QUOTE,FIXLEN=10)),              $ PINCODE   
  BUILD=(%01,JFY=(SHIFT=LEFT,PREBLANK=C'"'),               
         %02,JFY=(SHIFT=LEFT,PREBLANK=C'"'),               
         %03,JFY=(SHIFT=LEFT,PREBLANK=C'"'),               
         %04,JFY=(SHIFT=LEFT,PREBLANK=C'"'),               
         %05,JFY=(SHIFT=LEFT,PREBLANK=C'"'),               
         %06,JFY=(SHIFT=LEFT,PREBLANK=C'"'))               

Only downside seems to be intensionally prefixed blanks are removed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
Search our Forums:

Back to Top