MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting a file in .CSV format

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
yatri
Beginner


Joined: 23 Aug 2005
Posts: 12
Topics: 10

PostPosted: Wed Aug 31, 2005 6:18 am    Post subject: Sorting a file in .CSV format Reply with quote

I have a file like the one below. It comes in as a CSV format

Code:

10,20,superstore,London
200,3999,metro,Edinburgh


1st field max 5 digit (say it is item code)

2nd field max 5 digit (say it is the amount),

3rd field 20 char max (say is store id) and

4th field 30 char max (say is the city)

My output file should be as follows

Code:

00010,00020,superstore          ,London                       
00200,03999,metro               ,Edinburgh


Can this be done using sort card alone?
_________________
Thanks,
Gayatri.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 31, 2005 12:56 pm    Post subject: Reply with quote

Frank,

Is it possible to solve this using OVERLAY function?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 31, 2005 1:21 pm    Post subject: Reply with quote

yatri,

If rexx is a choice , then the following will rexx exec will give you the desired results.

Code:

/* REXX */                                               
IN_STR  = '10,20,SUPERSTORE,LONDON'                       
PARSE VAR IN_STR HLQ ',' MLQ ',' TLQ ',' FLQ             
SAY RIGHT(HLQ,5,'0') || ',' || RIGHT(MLQ,5,'0') ||,       
    ',' || LEFT(TLQ,20,' ') || ',' || LEFT(FLQ,30,' ')   


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Aug 31, 2005 2:06 pm    Post subject: Reply with quote

Quote:
Is it possible to solve this using OVERLAY function?


OVERLAY? You mean IFTHEN? Maybe, with a very complex set of IFTHEN clauses, but I don't have time to attempt it. Using REXX or an exit probably makes more sense.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 31, 2005 3:45 pm    Post subject: Reply with quote

Frank,

yep ! I meant Overlay with IFTHEN . But I guess it would be a complex IFTHEN

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Thu Sep 01, 2005 1:06 am    Post subject: Reply with quote

Hi,
U can use the Exit routine with Rexx to slove the problem easily as mentioned by Frank.
I modified the Kolusu's Rexx to fit into the Sort.Here is the solution.

Sort :
Code:

//STEP0200 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SYSLIN   DD DSN=&S1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//SYSLMOD  DD DSN=&S2,DISP=(,PASS),SPACE=(CYL,(1,1,2),RLSE) 
//SORTIN   DD *                                             
10,20,SUPERSTORE,LONDON                                     
200,3999,METRO,EDINBURGH                                     
//SORTOUT  DD SYSOUT=*                                       
//SYSTSPRT DD SYSOUT=*                                       
//MODLIB   DD DSN=xx.xx(put the Rexx routine TEST here),
//               DISP=SHR                                       
//SYSIN DD *                                                 
  SORT FIELDS=COPY                                           
  MODS E15=(TEST,133,MODLIB,X)                               
/*                                                           

Test :

Code:

/* REXX */
ADDRESS 'SYNCREXX' 'GIVE'
LS = LENGTH(SYRECORD)
IF LS > 0
   THEN DO
     SYACTION = 'REPLACE'
     PARSE VAR SYRECORD HLQ ',' MLQ ',' TLQ ',' FLQ
     SYRECORD = RIGHT(HLQ,5,'0') || ',' || RIGHT(MLQ,5,'0') ||,
                ',' || LEFT(TLQ,20,' ') || ',' || LEFT(FLQ,30,' ')
     SAY RC
   END
ELSE DO
   SYACTION = 'CLOSE'
END
ADDRESS 'SYNCREXX' 'TAKE'
RETURN                                                           

Hope this will help.
Thank you
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Apr 24, 2006 3:43 pm    Post subject: Reply with quote

Here's a DFSORT job that will do what was requested. It uses the PARSE and %nn functions available with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006). See the following for more information on all of the new DFSORT/ICETOOL functions available with these PTFs:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT  DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC PARSE=(%00=(FIXLEN=5,ENDBEFR=C','),
               %01=(FIXLEN=5,ENDBEFR=C','),
               %02=(FIXLEN=20,ENDBEFR=C','),
               %03=(FIXLEN=30,ENDBEFR=C' ')),
  BUILD=(%00,UFF,M11,LENGTH=5,C',',
         %01,UFF,M11,LENGTH=5,C',',
         %02,C',',
         %03)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
u0z72b6
Beginner


Joined: 28 Apr 2006
Posts: 2
Topics: 0

PostPosted: Fri Apr 28, 2006 4:56 am    Post subject: Reply with quote

Althoug with new last features of df/sort this problem is easyer, it takes my attention the use of REXX to code E15 EXIT directly.
But I tried to test it and unfortunately the fourth parameter "X" in MODS is wrong. The $ sign is under the "X"

Code:

ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED
ICE000I 1 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 11:47 ON
            SORT FIELDS=COPY
            MODS E15=(I@PARSOR,133,MODLIB,X)
                                          $
                                                                 
ICE034A D MODS STATEMENT OPERAND ERROR
ICE052I 3 END OF DFSORT

I can't find any information in manuals about it. I am using the DF/SORT R14 with UK90006 applied.

Thanks for help. Thanke you
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Apr 28, 2006 10:33 am    Post subject: Reply with quote

DFSORT does NOT support REXX exits.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
u0z72b6
Beginner


Joined: 28 Apr 2006
Posts: 2
Topics: 0

PostPosted: Tue May 09, 2006 2:10 am    Post subject: Reply with quote

Thanks a lot. I prefer use Assembler for this.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue May 09, 2006 10:49 am    Post subject: Reply with quote

DFSORT does support Assembler exits. But since you have the April, 2006 PTF, you can use PARSE as shown and you don't need an exit.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group