I have more than 100 columns in a file and I want to apply TRIM function to all the columns. Is there any quick way of applying this function, instead of calling this function for each column in Transformer stage ???
Thanks
applying trim function to all the columns in a file
Moderators: chulett, rschirm, roy
If you are on unix and, say your input file is pipe '|' delimited, you can very quick use sed to do the replacement:
Code: Select all
PRG=$( basename $0 )
#* Check if file exists, bail if it doesn't.
if [ -f $1 ]; then
sed -e 's/[ ]*|/|/g' $1
else
echo "$PRG: Non existant file provided: $1"
exit 1
fi
This solution only trim the right side of the field. Trim() is capable of eliminating leading along with trailing spaces.1stpoint wrote:If you are on unix and, say your input file is pipe '|' delimited, you can very quick use sed
Code: Select all
sed -e 's/[ ]*|[ ]*/|/g' $1
Wow, first time I ever used sed...
-T.J.
Developer of DataStage Parallel Engine (Orchestrate).