Page 1 of 1

Replacing Carriage Returns in fields

Posted: Sun Jul 17, 2005 5:15 pm
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

Posted: Sun Jul 17, 2005 10:33 pm
by kcshankar
Hi,
Welcome aboard

Posted: Sun Jul 17, 2005 10:49 pm
by chulett
Convert and Ereplace are two of the weapons of choice here. Searching the forum would turn up several examples like this one.

Posted: Mon Jul 18, 2005 12:23 am
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.

Posted: Mon Jul 18, 2005 4:35 am
by tjmalone
Thanks for the help

Posted: Tue Jul 19, 2005 2:38 pm
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

Posted: Tue Jul 19, 2005 9:50 pm
by chulett
There are specific syntax examples in the post I linked to above.

Posted: Wed Jul 20, 2005 11:03 am
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

Posted: Wed Jul 20, 2005 9:18 pm
by ray.wurlod
:idea:
Next time your project is reviewed, simplify the code and reap the throughput performance benefits.

Posted: Thu Jul 21, 2005 12:07 am
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.