How to handle Control M Character
Moderators: chulett, rschirm, roy
How to handle Control M Character
HI Guys,
Did anyone come across handling Control M charaters .
I have a .csv file and when i look into it, it has a CntrlM(^M) character at the end of each record..
i tried different delimiters for cntl m but it didnt work out....is ther any work around for this issue..
thanks
shisheer
Did anyone come across handling Control M charaters .
I have a .csv file and when i look into it, it has a CntrlM(^M) character at the end of each record..
i tried different delimiters for cntl m but it didnt work out....is ther any work around for this issue..
thanks
shisheer
"Attitude always and almost determines the altitude of your Life"
Re: How to handle Control M Character
u can clean the file before processing using sed command.kool78 wrote:HI Guys,
Did anyone come across handling Control M charaters .
I have a .csv file and when i look into it, it has a CntrlM(^M) character at the end of each record..
i tried different delimiters for cntl m but it didnt work out....is ther any work around for this issue..
thanks
shisheer
Or vi the file and use substitution to remove all the ^M's
Code: Select all
:%s/^M//g
Narasimha Kade
Finding answers is simple, all you need to do is come up with the correct questions.
Finding answers is simple, all you need to do is come up with the correct questions.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
... or set the Final Delimiter property to \R
... or create a dummy Char(1) column and set it's "drop on import" property to True
There's always more than one way to do something in DataStage.
... or create a dummy Char(1) column and set it's "drop on import" property to True
There's always more than one way to do something in DataStage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi all,
Thanks for the replies...
I dont want to process the file before...
but i was trying the options mentioned by Ray...i used \R but still im unable to view the data....its throwing the error as delimiter for hte filed(last filed) is not found..
it would be grt if can you throw more light on this ray...
thanks
Thanks for the replies...
I dont want to process the file before...
but i was trying the options mentioned by Ray...i used \R but still im unable to view the data....its throwing the error as delimiter for hte filed(last filed) is not found..
it would be grt if can you throw more light on this ray...
thanks
"Attitude always and almost determines the altitude of your Life"
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Which of the methods did you try? The second (create an extra column) will fail with the message you got, because there is no actual delimiter character between the last column and the \r character.
What is the data type of the last field in your data record?
Did you try setting the final delimiter property to \r ? If it won't take more than one printable character, try using 013 (the decimal value of the ASCII code point).
What is the data type of the last field in your data record?
Did you try setting the final delimiter property to \r ? If it won't take more than one printable character, try using 013 (the decimal value of the ASCII code point).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi rayray.wurlod wrote:Which of the methods did you try? The second (create an extra column) will fail with the message you got, because there is no actual delimiter character between the last column and the \r character.
...
I tried the first method..
have set the Final Delimiter property to \R but didnt work out..
one morething i observed is ..when i used record delimiter strins as : DOS Format..it was working fine..
but im not sure whether if the source file is ftp'd from windows to unix..does it have unix newline or dos format...
thanks
"Attitude always and almost determines the altitude of your Life"
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Last time I looked (7.5.1), "DOS format" was not available for record delimiter when running on UNIX platform. Otherwise I would have cited that as the appropriate technique.
The only way to know what's there is to look at the actual characters. If you have a hex editor, such as UltraEdit, use that. Otherwise you can use the UNIX od command.
The only way to know what's there is to look at the actual characters. If you have a hex editor, such as UltraEdit, use that. Otherwise you can use the UNIX od command.
Code: Select all
head -3 filename | od -xc
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Wasn't that what I quoted from the Developer's Guide?ray.wurlod wrote:Last time I looked (7.5.1), "DOS format" was not available for record delimiter when running on UNIX platform. Otherwise I would have cited that as the appropriate technique.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 10
- Joined: Wed Feb 08, 2006 1:08 am
- Location: Hyderabad
Hi ray
I tried the first method..
have set the Final Delimiter property to \R but didnt work out..
one morething i observed is ..when i used record delimiter strins as : DOS Format..it was working fine..
but im not sure whether if the source file is ftp'd from windows to unix..does it have unix newline or dos format...
I too faced similar problem.. I think it is due to the file FTP from windows to unix server.
While ftp'ing the file use command "ascii" (by default it is "bin" - binary), and then ftp the file... Use SSH Clients and ftp the file in ASCII format.. This should solve the problem..
Regards,
Asish
Typically - yes. Or sometimes people map a UNIX drive in Windows and just drag and drop files.Th3Und34D- wrote:I too faced similar problem.. I think it is due to the file FTP from windows to unix server.
ps. That won't "solve" the problem, per se. To solve it one would need to be able to read and handle DOS files properly. An 'ascii' ftp transfer would eliminate the need to solve the problem.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 22
- Joined: Mon Apr 02, 2007 4:02 am
- Location: MUMBAI
- Contact:
You can try this
Hi ,
you can try the following option :
While saving the file in Unix ( i guess u r using this platform) just type the below command
%s/^M//
Cheers
you can try the following option :
While saving the file in Unix ( i guess u r using this platform) just type the below command
%s/^M//
Cheers
Smrutiranjan Nayak
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 10
- Joined: Wed Feb 08, 2006 1:08 am
- Location: Hyderabad
Haaa... Finally i got a resolution for this.
I got a solution. It solved my purpose of removing ^M.
Use Iconv("Column where ^M is present", "MCP")
With MCP option ur problem will b solved ... :D
Regards,
Asish Koyya
Use Iconv("Column where ^M is present", "MCP")
With MCP option ur problem will b solved ... :D
Regards,
Asish Koyya