Removing \n char in the field
Moderators: chulett, rschirm, roy
Removing \n char in the field
Hi Friends,
I want to replace the char \n with "" from my inp data. I tried it using the convert function. But it takes the unix end of line as \n and replace with " ".
Inp Data: qwerbv\nqewtt\n
Required O\P data: qwerbvqewtt
I tried using the external filter with sed 's/\\n/ /'. its not working out.
Please let me know abt this.
Thanks,
Senthil P
I want to replace the char \n with "" from my inp data. I tried it using the convert function. But it takes the unix end of line as \n and replace with " ".
Inp Data: qwerbv\nqewtt\n
Required O\P data: qwerbvqewtt
I tried using the external filter with sed 's/\\n/ /'. its not working out.
Please let me know abt this.
Thanks,
Senthil P
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
When you say you get "\n" in the input do you mean the actual string "\n" or the line feed character. If you want to remove line feeds then what Arndw says should work for you. If you are trying to remove the literal "\n" from your input string then you can escape the backslash while using convert to get the desired output.
The above code should do the trick.
Code: Select all
Convert("\\n","",link.column)
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
Wait a minute, I don't know what I was thinking
Convert replaces all the characters present in the first argument with the second argument. So the above code would also remove "n"s and "\"s from your string which is not what you want. You can use Ereplace to do this, But since your's is a parallel job you won't be able use Ereplace (There is parallel routine on Ereplace posted in DSXchange though..)
You can create a simple unix script which would replace the offending "\n" with empty string in a before job routine and then process it.
![Embarassed :oops:](./images/smilies/icon_redface.gif)
Convert replaces all the characters present in the first argument with the second argument. So the above code would also remove "n"s and "\"s from your string which is not what you want. You can use Ereplace to do this, But since your's is a parallel job you won't be able use Ereplace (There is parallel routine on Ereplace posted in DSXchange though..)
You can create a simple unix script which would replace the offending "\n" with empty string in a before job routine and then process it.
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Thanks Arndw and Minhajuddin,
Convert function replaces all the characters - as Minhajuddin said. So i should not use Convert funtion for my case. we can easily do this thro unix, but wont there be any other way to replace the literal \n with " " thro Datastage?
Please let me know if there is anything,
Thanks,
Senthil P
Convert function replaces all the characters - as Minhajuddin said. So i should not use Convert funtion for my case. we can easily do this thro unix, but wont there be any other way to replace the literal \n with " " thro Datastage?
Please let me know if there is anything,
Thanks,
Senthil P
If you need to replace the literal string(i.e if it is not a linefeed) '\n', then you need the ereplace equivalent. Dsguru2b has a version on this forum (there is also one I wrote, but it is pretty much untested, so I don't reccomend it)
You can try sed 's,\\n, ,g'
Sed can basically use any char after the first command. So if you have your \s and /s messing things up, just use any other character as your regex delimter.
Regards,
D
Edited as I missed a \
You can try sed 's,\\n, ,g'
Sed can basically use any char after the first command. So if you have your \s and /s messing things up, just use any other character as your regex delimter.
Regards,
D
Edited as I missed a \
Last edited by iDomz on Thu Jun 05, 2008 4:03 am, edited 1 time in total.
Ok, I have misunderstood your problem. Your real question is "how do I change the string '\n' to a single space?"
One answer is to use a filter of "sed 's/\\n/ /'" in your sequential file stage, as you have already mentioned in your first post. I just wrote a small test job and can confirm that this filter works correctly.
One answer is to use a filter of "sed 's/\\n/ /'" in your sequential file stage, as you have already mentioned in your first post. I just wrote a small test job and can confirm that this filter works correctly.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: