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

Sort for a csv File


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 9:56 pm
Reply with quote

Hi .. I have a VB file having comma separated values. I have to write three fields from each record. Could you please help me with the sort card?

I will give you a example:

I/p File

07Dec2011,0B00NY175,G92450SD1,UKIN,Utd Kdom Gt Britn & Nthn Irlnd,GBP,SNRFOR,07Dec2038,,4.75
07Dec2011,IT000493,,ITALY,Rep Italy,EUR,SNRFOR,01Feb2018,,4.5,6M,Fixed,IBoxx,Xtrakter,Quotes
07Dec2011,IT00493,,ITALY,Rep Italy,EUR,SNRFOR,01Feb2018,,4.5,6M,Fixed,IBoxx,Xtrakter,Quotes

0/p File :
0B00NY175 UKIN
IT000493 ITALY
IT00493 ITALY

This is just an example but for my requirement there are so many field before the required field.
Is it possible that we can count commas in the record and then write after the count of commas
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 09, 2011 10:02 pm
Reply with quote

How many is "so many"? Is it more than 100? PARSE can handle 100 fields at a time.

You mention three fields, but your required output only shows two.

If you can get us some more detailed information...
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:08 pm
Reply with quote

Bill Woodger wrote:
How many is "so many"? Is it more than 100? PARSE can handle 100 fields at a time.

You mention three fields, but your required output only shows two.

If you can get us some more detailed information...


Thanks Bill for the quick reply....
Yes my o/p will only contain two fields

I have around 24 fields in front of the required field , I have used ENDBEFR for such kind of requirement earlier
OUTREC PARSE=(%01=(ENDBEFR=C'¦',FIXLEN=12),
%02=(ENDBEFR=C'¦',FIXLEN=01),
%03=(ENDBEFR=C'¦',FIXLEN=02),
%04=(ENDBEFR=C'¦',FIXLEN=180),
%05=(ENDBEFR=C'¦',FIXLEN=30),
%06=(ENDBEFR=C'¦',FIXLEN=30),
%07=(ENDBEFR=C'¦',FIXLEN=30),
%08=(ENDBEFR=C'¦',FIXLEN=30),
%09=(ENDBEFR=C'¦',FIXLEN=30),
%10=(ENDBEFR=C'¦',FIXLEN=30),
%11=(ENDBEFR=C'¦',FIXLEN=30)),

but is it possible to achieve this by some other command or skipping few fields instead of extracting each
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Dec 09, 2011 10:09 pm
Reply with quote

kamiya jain,

You can use DFSORT PARSE function to scan upto 100 fields. You can ignore the ones you don't need. Since your input is a VB file your actual data starts from position 5. Use the following DFSORT JCL which will create a VB file with the fields 2 and 4.

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD DSN=Your input VB file,DISP=SHR       
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  SORT FIELDS=COPY

  INREC PARSE=(%=(ABSPOS=5,ENDBEFR=C','),           
               %01=(ENDBEFR=C',',FIXLEN=15),         
               %=(ENDBEFR=C','),                     
               %02=(ENDBEFR=C',',FIXLEN=10)),       
        BUILD=(1,4,%01,%02)                         

//*
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:22 pm
Reply with quote

Thanks Skolusu ,

I have around 24 field in front of my one of the required field then I have to skip around 25 field after that I have a required field.

So I was thinking is it possible to sort that without using endbefr .
because the sort card will be very big in this case
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Dec 09, 2011 10:29 pm
Reply with quote

kamiya jain wrote:

So I was thinking is it possible to sort that without using endbefr .
because the sort card will be very big in this case


DFSORT is smart enough to process and ignore the fields when you parse with just %= .
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:37 pm
Reply with quote

Code:

  SORT FIELDS=COPY,SKIPREC=1                                     
  OUTREC PARSE=(%=ABSPOS=5,ENDBEFR=C','),                         
              %=(ENDBEFR=C','),                                 
              %01=(ENDBEFR=C',',FIXLEN=12),                     
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
              %=(ENDBEFR=C','),                                 
  %=(ENDBEFR=C','),                         
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %02=(ENDBEFR=C',',FIXLEN=18),           
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
  %=(ENDBEFR=C','),                       
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %=(ENDBEFR=C','),                   
              %03=(ENDBEFR=C',',FIXLEN=18)),     
  BUILD=(1:%01,14:%02,45:%52)             


I tried this sort card but it is not working icon_sad.gif
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 10:44 pm
Reply with quote

Its working ... but is it possible to make o/p file as FB file . Please reply
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Dec 09, 2011 11:05 pm
Reply with quote

kamiya jain,

The reason your sort card did not work is you trying to overlay the RDW of the VB file. You canNOT overlay the contents of RDW. If you want an FB file then add the following statement. The 3 fields you interested are (12+18+18 =48 bytes)

Code:

  OUTFIL VTOF,BUILD=(5,48)


PS: Don't Quote the whole post.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 09, 2011 11:06 pm
Reply with quote

Yes, it is possible.

Are you going with fixed positions/lengths for your output? Also are the chunks of record beyond the field length deliberate? Your output example from your first post wasn't clear on this.

If you can give your start positions and lengths, it'll help.
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 11:32 pm
Reply with quote

Bill ,

Yes I have fixed positions/lengths for o/p.
There are around 52 field in a record and I require 2nd ,26th and 52nd field of the csv file.

I have tried using endbefr field but the sort card is too lengthy and I need a o/p file to be FB rather then VB.

I hope I am able to put my exact requirement
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 09, 2011 11:39 pm
Reply with quote

What do you mean by the sort card being too lengthy? It'll be as long as it needs to be, and needn't be longer. If that is in some way too long, then you'll have to look for another solution, maybe write a program.

Making the output dataset FB is not a problem.

I asked about the start positions and lengths of your output fields, as in what they are, rather than do you have them as a yes/no answer. You currently have "gaps" from the latest you have shown. Do you want those as well?
Back to top
View user's profile Send private message
kamiya jain

New User


Joined: 18 Aug 2009
Posts: 7
Location: Mumbai

PostPosted: Fri Dec 09, 2011 11:59 pm
Reply with quote

I means to say that sort card was too big...but I am coding that way only.
I used the above posted sort card and it worked fine..
Thank You so much for the help... icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Dec 10, 2011 12:24 am
Reply with quote

kamiya jain wrote:
I means to say that sort card was too big...but I am coding that way only.
I used the above posted sort card and it worked fine..
Thank You so much for the help... icon_smile.gif


Thanks for the feedback. Glad it's working.

The last line is for Kolusu, I've checked, I didn't post a line of code, and I still don't understand the "too big"/long thing, but there we go. :-)
Back to top
View user's profile Send private message
retrostrings

New User


Joined: 21 Jan 2021
Posts: 1
Location: Canada

PostPosted: Thu Jan 21, 2021 10:12 pm
Reply with quote

Hi all,


Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.

This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.

Thanks very much!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Jan 21, 2021 11:40 pm
Reply with quote

retrostrings wrote:
Hi all,


Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.

This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.

Thanks very much!

Use ENDAT= instead of ENDBEFR=
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Fri Jan 22, 2021 1:30 am
Reply with quote

retrostrings wrote:
Hi all,


Is there a way to use Parse and Build in SORT to include commas from the csv file? Using ENDBEFR = C'","' and fixed lengths copies data just before the comma. I have a requirement to split a csv file into two files. So fields 1 through 5 go on one file as it is while the remaining fields go on another file. I do not want to get rid of the commas or the enclosed double quotes. Appreciate any pointers please.

This is my first post, I'm sorry if I did not adhere to best practices related to posting but I'll be quick to adapt.

Thanks very much!

Welcome!
Next time , Please start a new post with your problem statement instead of tailgating any older posts as that's one of the rule and do search this forum before posting as it might have already been discussed before and you could use that solution.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top