Page 1 of 1

Handling spaces

Posted: Sat Jan 07, 2012 11:01 am
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?

Posted: Sat Jan 07, 2012 12:25 pm
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.

Posted: Sat Jan 07, 2012 12:47 pm
by chulett
For a fixed-width file? I think not.

Posted: Sat Jan 07, 2012 12:54 pm
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)

Re: Handling spaces

Posted: Sat Jan 07, 2012 12:57 pm
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.

Posted: Sat Jan 07, 2012 2:10 pm
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.

Posted: Sat Jan 07, 2012 3:53 pm
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.

Posted: Sat Jan 07, 2012 8:08 pm
by vskr72
Awesome. Thank you Ray/Eric. This saves a lot of time.