Replacing Carriage Returns in fields

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
tjmalone
Participant
Posts: 8
Joined: Thu Jul 14, 2005 7:06 pm

Replacing Carriage Returns in fields

Post by tjmalone »

Firstly apologies if this is simple to do, or already has been explained.

Basically what I need to do is replace all carriage returns in a fixed width file (other than those that fall at end of the rows). Preferable without playing around with the metadata.

Any help or guidance on this problem would be greatly appreciated.

Thanks for yor time

tjmalone
kcshankar
Charter Member
Charter Member
Posts: 91
Joined: Mon Jan 10, 2005 2:06 am

Post by kcshankar »

Hi,
Welcome aboard
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Convert and Ereplace are two of the weapons of choice here. Searching the forum would turn up several examples like this one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Be careful if you're really on Windows, which your original post specifies. The Windows line termination sequence is actually two characters, made up of a line feed and a carriage return.
Since Convert() only does character-by-character conversion, you would definitely need Ereplace() - which does substring substitution - or Change() which is a subset of Ereplace() functionality.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
tjmalone
Participant
Posts: 8
Joined: Thu Jul 14, 2005 7:06 pm

Post by tjmalone »

Thanks for the help
sumitgulati
Participant
Posts: 197
Joined: Mon Feb 17, 2003 11:20 pm
Location: India

Post by sumitgulati »

tjmalone wrote:Thanks for the help
Hi tjmalone, did it work for you. If yes could you please send me the exact that you used. Actually we were facing a similar issue in our project but we didn't know using EReplace or Convert how do we first read a CR or LF value. So, what we did was we used Iconv Oconv to convert them to ASCII, removed CR and LF and converted them back to normal form. After going through this post I feel there could be an easier way achieve it. Would really appreciate if you could send me the exact code that you have used.

Thanks in advance,
-Sumit
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There are specific syntax examples in the post I linked to above.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sumitgulati
Participant
Posts: 197
Joined: Mon Feb 17, 2003 11:20 pm
Location: India

Post by sumitgulati »

chulett wrote:There are specific syntax examples in the post I linked to above.
Thank Chulett. This is so simple. What we have done in our project is very complicated compared to this.

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

Post by ray.wurlod »

:idea:
Next time your project is reviewed, simplify the code and reap the throughput performance benefits.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
tjmalone
Participant
Posts: 8
Joined: Thu Jul 14, 2005 7:06 pm

Post by tjmalone »

Well, the job actually got assigned to some one else, but one option i was considering is bringing the table in as a single stream, removing all line breaks, carriage returns. And then calling a created routine that loop throughs using a substring based on the job parameter specifying the width of the complete row (fixed width table), and then adding a carriage return to it.

Though never actually tried this. And not sure how it would go, as i've quite new to this.
Post Reply