Page 1 of 1

Remove trailing SPACES using SORT.

Posted: Sat Jan 07, 2017 6:54 pm
by BobThomas
Hi,

From an input file I want to remove the trailing spaces after the value of the filed and before the commausing SORT. For example, please consider the data like this:

Code: Select all

11,A B C D ,abc  , 
12,xxyy zz ,xyz  some place   , 
13,xxyz ,xyz  other avenue , 
The output file should like this:

Code: Select all

11,A B C D ,abc, 
12,xxyy zz ,xyz  some place, 
13,xxyz ,xyz  other avenue, 
Could anyone please suggest a way of doing this?

Re: Remove trailing SPACES using SORT.

Posted: Sat Jan 07, 2017 8:44 pm
by nicc
Will it always be the same number of fields? Your example shows each record having 3 fields.

Re: Remove trailing SPACES using SORT.

Posted: Tue Jan 10, 2017 11:40 am
by BobThomas
Thanks for the answer. Yes, it will always be same number of fields.

Re: Remove trailing SPACES using SORT.

Posted: Wed Jan 11, 2017 11:14 pm
by William Collins
Use FINDREP to change C' ,' to C''

Re: Remove trailing SPACES using SORT.

Posted: Thu Jan 12, 2017 2:21 pm
by BobThomas
But that removes the sapce for second field also, I want to remove teh sapce for third filed only.

Re: Remove trailing SPACES using SORT.

Posted: Sat Jan 14, 2017 1:35 pm
by William Collins
Sorry, missed that part as it only appeared with the data :-)

Two techniques. Use FINDREP with DO=2 to change comma to X'FD' (or any non-display value). Use FINDREP to change the spaces-and-comma (you'll need multiple, it looks like, as you don't have a fixed number of trailing spaces). This can be DO=1. Use FINDREP again to change the non-display value back to comma (DO=2).

Use JFY. SHIFT=RIGHT to maximum record-length. SHIFT=RIGHT to entire record except the "." which is in the right-most position. SHIFT=LEFT for the entire record.

Re: Remove trailing SPACES using SORT.

Posted: Wed Jan 18, 2017 11:04 am
by BobThomas
Thank you.