Handling spaces

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
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Handling spaces

Post by vskr72 »

There are lot of source files which are fixed width and I am using 'CHAR' to read them and it works well. It also turns out that I get spaces in certain columns because of this. There are more than 80 files and each file has 200+ columns. Is there any way to handle these other than using a Trim in transformer for each column. That may take a long time. Any suggestions?
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

If you bother about using transformer, use the filter option in sequential file stage .
Just check whether the below sed satisfy your need.

Code: Select all

Sed 's/ //g'
Thanks.
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For a fixed-width file? I think not.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Yes Craig! you are correct.
I believe there is no other options other than using transformer.
Convert() will handle this(even if the spaces are in between)
Last edited by pandeesh on Sat Jan 07, 2012 12:58 pm, edited 1 time in total.
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Re: Handling spaces

Post by pandeesh »

vskr72 wrote:It also turns out that I get spaces in certain columns because of this.?
"Because of this" part is ambiguous.
The spaces are there in the data in file itself and not because of reading as CHAR.Please correct me if i am incorrect.
pandeeswaran
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

You may be able to use the find/replace in the Transformer stage editor to put all the trim or convert functions in at once.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You do this (what Eric suggested) using "derivation substitution". Select all the columns that you want to change in the output link of the Transformer stage (the ones that are CHAR coming in and VARCHAR going out), right click, choose Derivation Substitution, enter "Trim($1)" as the expression and commit. Magic happens.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Post by vskr72 »

Awesome. Thank you Ray/Eric. This saves a lot of time.
Post Reply