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

Sorting comma separated file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

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

Have a look at 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: 577
Location: USA

PostPosted: Wed Aug 25, 2010 7:11 pm
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

Moderator Emeritus


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

PostPosted: Wed Aug 25, 2010 8:09 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Aug 25, 2010 8:16 pm
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: 577
Location: USA

PostPosted: Wed Aug 25, 2010 8:29 pm
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

Moderator Emeritus


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

PostPosted: Wed Aug 25, 2010 8:39 pm
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
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: 1702
Location: Australia

PostPosted: Thu Aug 26, 2010 11:29 am
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top