TRIM

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
panic
Participant
Posts: 17
Joined: Fri Sep 23, 2005 5:58 pm

TRIM

Post by panic »

Hi all

I HAVE to trim trailing special character |
or just replace with blank while trimimg
can any one please let me know the syntax



how to use exactly
Trim(%string%,[%stripchar%],[%option%])

thanks
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

What is your source? The special character you are talking about is LineFeed or are you talking about a PIPE.You cannot use TRIM function in order to trim a LF(LineFeed) it. If you can let us know what your source is we can then go about it.
Kris

Where's the "Any" key?-Homer Simpson
avi21st
Charter Member
Charter Member
Posts: 135
Joined: Thu May 26, 2005 10:21 am
Location: USA

Post by avi21st »

Hi Panic :D

First thing - do you know what character you are having. What you see as special character in your Editor is not the true identifier of what is coming in data...If you are sure of the special chatacer- Then yes, you can do a field level modification by using TRIM

Code: Select all

Use TRIM( linkname.columnname, 'Character to replace','A')
OR you can use a before job routine (ExecSh) to change all the characters in the input file.

For example this one is used to remove non ascii fields:

Code: Select all

tr '\0' ' ' < #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME# > #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME_CLN#

where

tr is for translate in UNIX
'\0' is the character to replace
' ' is the character by which you want to replace
< #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME# > is the input file
#TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME_CLN# is the cleaned file

Let me know if you are still panicking!!!! :o
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Re: TRIM

Post by meena »

Hi Panic...
Can you let us know what is your source and what your job is doing...The special character looks like a pipe..and if you want to replace the character by blank then I think we can use 'Replace' function..
panic wrote:Hi all

I HAVE to trim trailing special character |
or just replace with blank while trimimg
can any one please let me know the syntax



how to use exactly
Trim(%string%,[%stripchar%],[%option%])

thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Either the on-line Help or the DataStage BASIC manual will give you complete descriptions of the Trim() function. You could also use the string_trim() function in a Modify stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Make sure you are not working with a pipe delimited file ....lol
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Hi:

How to eliminate a non-ascii charecter dynamically? I mean to say...I do not know what non-ascii char I would get in my source file but i need to search for non- ascii chars and clean up the file before loading into target table.

Basically my source file is from SAP. So, I can say non-ascii char would be a Korean/Japanese/chinese language specific.

I am not very good at Shell scripting. please help me out solving this.

thanks,
avi21st wrote:Hi Panic :D

First thing - do you know what character you are having. What you see as special character in your Editor is not the true identifier of what is coming in data...If you are sure of the special chatacer- Then yes, you can do a field level modification by using TRIM

Code: Select all

Use TRIM( linkname.columnname, 'Character to replace','A')
OR you can use a before job routine (ExecSh) to change all the characters in the input file.

For example this one is used to remove non ascii fields:

Code: Select all

tr '\0' ' ' < #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME# > #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME_CLN#

where

tr is for translate in UNIX
'\0' is the character to replace
' ' is the character by which you want to replace
< #TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME# > is the input file
#TARGET_FILE_DIRECTORY#/#OUTPUT_FILE_NAME_CLN# is the cleaned file

Let me know if you are still panicking!!!! :o
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If they are Chinese-Japanese-Korean (CJK) characters are you sure you want to eliminate them? They are probably valid data. More likely you need to preserve them, would be my guess.

This means that you need DataStage National Language Support (NLS) installed, configured and the appropriate character map(s) chosen. Read more about it in the DataStage NLS manual. There is overlap of some characters in the CJK encodings.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

I am sorry for the confusion Ray. Actually we have NLS installed and configured. I mentioned Chinese-japanese-korean as an example to explain the problem. But I do not know what type of non-ascii I would be getting.

-thanks.

ray.wurlod wrote:If they are Chinese-Japanese-Korean (CJK) characters are you sure you want to eliminate them? They are probably valid data. More likely you need to preserve them, would be my guess.

This means that you need DataStage National Language Support (NLS) installed, configured and the appropriate character map(s) chosen. Read more about it in the DataStage NLS manual. There is overlap of some characters in the CJK encodings.
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Maybe you could test the rightmost character with IsValid() to determine whether it is a valid string. A character that is valid as a ustring but not as a string might fall into your "non-ASCII" class.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply