Insert a delimiter using sort.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Insert a delimiter using sort.

Post by Manish Arora »

Hi All,

I need to insert a delimiter(|) between two columns, how can I do that:

File1:

Code: Select all

NO# NAME ID 
123 AAAA 1 
456 BB   10 
789 CCC  2 
This should be converted into

Code: Select all

NO# NAME ID 
123|AAAA|1 
456|BB  |10 
789|CCC |2 
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Insert a delimiter using sort.

Post by zprogrammer »

Are the fields of fixed length and do you know in which position you wanted to place the delimiter (|) ?
zprogrammer
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

Hi Pandora-Box,

No, the fields length can vary. After every word (identified by at least once space in between) I need the delimiter.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Insert a delimiter using sort.

Post by William Collins »

Do you want to replace spaces which indicate a break of field, or retain them? Do you have any field with an embedded space, like a name and surname in the same field?

Can you explain, and show some representative input and expected output for that?
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

Hi William,

I want to replace the spaces which indicate a break of field. There is no space between name and surname. For example, I've the same input as I showed in previous post:

Code: Select all

NO# NAME ID 
123 AAAA 1 
456 BB   10 
789 CCC  2
expected output is:

Code: Select all

NO# NAME ID 
123|AAAA|1 
456|BB  |10 
789|CCC |2 
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

"NO# NAME ID " are jut indicative, they are not part of input.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Insert a delimiter using sort.

Post by zprogrammer »

Just trying to understand better Should it be like this

Code: Select all

NO# NAME ID
123|AAAA|1
456|BB  |10
789|CCC |2
or like this

Code: Select all

NO# NAME ID
123|AAAA|1
456|BB|10
789|CCC|2
zprogrammer
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

Sorry I could not compherhend your question before. Yes, this will work.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Insert a delimiter using sort.

Post by William Collins »

Have a look at SQZ with MID=C'|', you should get it all in one shot.

Code: Select all

 INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C’|’))
That will take the data from position 1, length 80, shift all the data left by removing multiple spaces, and replacing them with a single space, then all single spaces, original or new, will be replaced by |.
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

Thanks. This worked.

Just reading your previous reply. In case I've to preserve the space between, say, first and surname. Can that be possible with a sort card like this, what consideration should i take. Please suggest.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Insert a delimiter using sort.

Post by William Collins »

Yes, you can "protect" a field (or as many as you need) by bounding it with quotes or apostrophes, tell the SQZ that you have done that, then take them off afterwards, with FINDREP.
Manish Arora
Registered Member
Posts: 14
Joined: Sun Aug 17, 2014 10:37 pm

Re: Insert a delimiter using sort.

Post by Manish Arora »

FINDREP is a revolutionary argument! Used it, liked it.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”