Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sorting comma separated file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Wed Aug 25, 2010 4:18 pm    Post subject: Sorting comma separated file
Reply with quote

I have a input file as below

12345,testing testing,324
9876,new testing,6759
567,test,78963
24345, new testing testing,32433


Length of the each field may vary for each record, i need to sort this file.
based on 3rd field.
i need the output as specified below.....

12345 testing testing 324
9876 new testing 6759
567 test 78963
24345 new testing testing 32433


I have searched this but i got info for fixed length fields. In my case its variable length... By using SORT how to get the output.....
Suggest me how to proceed....
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Aug 25, 2010 6:23 pm    Post subject:
Reply with quote

Have a look at http://www-947.ibm.com/systems/support/storage/software/sort/mvs/tricks/pdf/sorttrck.pdf where there's is information on processing CSV files. The PARSE function is what you need.

Garry.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 25, 2010 7:11 pm    Post subject: Re: Sorting comma separated file
Reply with quote

nareshdacha,

nareshdacha wrote:
I have a input file as below

12345,testing testing,324
9876,new testing,6759
567,test,78963
24345, new testing testing,32433


Length of the each field may vary for each record, i need to sort this file.
based on 3rd field.

i need the output as specified below.....

12345 testing testing 324
9876 new testing 6759
567 test 78963
24345 new testing testing 32433


I have searched this but i got info for fixed length fields. In my case its variable length... By using SORT how to get the output.....
Suggest me how to proceed....


You indicated that you want output sorted on 3rd field but I don't see your expected output sorted in any order.

Also, are you trying to create fixed byte file from the input CSV file? If yes, then please provide length of each field.

Please use code tags to preserve original format.

Thanks,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Aug 25, 2010 8:09 pm    Post subject:
Reply with quote

Hello,

Quote:
but I don't see your expected output sorted in any order.
The sample output is in order numerically by the 3rd field. . .

It just happens the input was already in sequence - not the best set of sample data. . .
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Aug 25, 2010 8:16 pm    Post subject:
Reply with quote

Quote:
have searched this but i got info for fixed length fields. In my case its variable length...


....and we would need to know the maximum length for each of the fields.


INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=??),
(%01=(ENDBEFR=C',',FIXLEN=??),
(%01=(ENDBEFR=C',',FIXLEN=??),
(
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 25, 2010 8:29 pm    Post subject:
Reply with quote

dick scherrer,
Unless I am missing any part of OP's post.

Quote:
The sample output is in order numerically by the 3rd field. . .

OP's expected output is

12345 testing testing 324
9876 new testing 6759
567 test 78963
24345 new testing testing 32433

If its sorted by 3rd field, shouldn't his last record, (3rd field =32433) appear before 3rd record (3rd field =78963)?

Thanks,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Aug 25, 2010 8:39 pm    Post subject: Reply to: Sorting comma separated file
Reply with quote

Good catch - i'm eye-lexic today (in addition to being key-lexic). . .

Looked at it multiple times and convinced myself that there were only 4 digits in the 7xxx number.

Been one of those weeks. . .

d
Back to top
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Thu Aug 26, 2010 11:17 am    Post subject: Reply to: Sorting comma separated file
Reply with quote

Thanks Garry....
Thank to all.....
I have gone thru the Garry's link and i got the output.....
Here a small question here....

My input is...

12345,target testing,9876
3456,new testing,987612
45672,testing,56789

Output is....

12345target testing 9876
3456new testing 987612
45672testing 56789

how to get the leading zeroes for the numeric fields if that field has less than specified length...

I need the output as follows:

12345target testing 009876
03456new testing 987612
45672testing 056789

Sort Card:

SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=5),
%01=(ENDBEFR=C',',FIXLEN=20),
%02=(FIXLEN=6)),
BUILD=(%00,%01,%02)
OUTREC BUILD=(1,5,SQZ=(SHIFT=RIGHT),6,20,26,6,SQZ=(SHIFT=RIGHT))

Can any suggest me ...........
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Aug 26, 2010 11:29 am    Post subject:
Reply with quote

Hi,

try this
Code:
 OUTREC BUILD=(1,5,SQZ=(SHIFT=RIGHT),6,20,26,6,UFF,M11,LENGTH=6) 



Gerry
Back to top
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Thu Aug 26, 2010 11:47 am    Post subject: Reply to: Sorting comma separated file
Reply with quote

Thanks Gcicchet,it worked out......

Thanks to all for your suggestion.......
Back to top
View user's profile Send private message
nareshdacha

New User


Joined: 12 Jan 2010
Posts: 66
Location: US

PostPosted: Thu Aug 26, 2010 1:27 pm    Post subject: Reply to: Sorting comma separated file
Reply with quote

My input is

1st field length = 5
2nd field length= 20
3rd field length=6

-2345,target testing,-9
-345,testing testing data,-89

I got the output like this

02345target testing 000009
02345testing testing data 000089

instead of sign symbol i got the space....

Required Output:
-02345target testing-000009
-00345testing testing data-000089

I have used the below sort card..

SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=5),
%01=(ENDBEFR=C',',FIXLEN=20),
%02=(FIXLEN=6)),
BUILD=(%00,%01,%02)
OUTREC BUILD=(1,5,UFF,EDIT=(STTTTT),SIGNS=(,'-','-','-'),6,20,
26,6,UFF,EDIT=(STTTTTT),SIGNS=(,'-','-','-'))

can anyone correct me..
Back to top
View user's profile Send private message
smijoss

Active User


Joined: 30 Aug 2007
Posts: 114
Location: pune

PostPosted: Thu Aug 26, 2010 2:28 pm    Post subject:
Reply with quote

a llittle research at your end, and u would have found out that
U of the UFF stands for UNSIGNED

for signed input u need to use SFF.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us