Replace space character with new line character in UNIX file

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
deepa_shenoy
Participant
Posts: 95
Joined: Thu Sep 24, 2009 12:15 am
Location: India

Replace space character with new line character in UNIX file

Post by deepa_shenoy »

Hi,

How can we replace space character with new line character in UNIX based file?

For example, if "Dsxchange is helpful" is coming in a single column, I want the ouput in a Sequential File to be in the below format:
Dsxchange
is
helpful

Thanks in advance.
Deepa
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Just replace the space with Char(10), you will get your required output.

Code: Select all

Ereplace(MyString, " ", Char(10)) 
Or
Convert(' ',char(10),MyString) 
I didnt test this code, please do the required changes.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Execute in sequential mode, or make sure that your collector re-assembles the lines in their correct order.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Even though Convert and EReplace may work, it will result in damaging the record as the target is a sequential file.

If you see the full picture, it will be something like
column1, column2, column3,...,Dsxchange is helpful,....,columnN
into
column1, column2, column3,...,Dsxchange
is
helpful,....,columnN
which may not make any sense
Post Reply