How to handle Control M Character

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

kool78
Participant
Posts: 104
Joined: Sat Aug 20, 2005 2:02 pm

How to handle Control M Character

Post by kool78 »

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
"Attitude always and almost determines the altitude of your Life"
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

^M is a <CR> and indicates DOS style record terminators.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Re: How to handle Control M Character

Post by pavankvk »

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
u can clean the file before processing using sed command.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... 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

:idea: 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.
kool78
Participant
Posts: 104
Joined: Sat Aug 20, 2005 2:02 pm

Post by kool78 »

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
"Attitude always and almost determines the altitude of your Life"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kool78
Participant
Posts: 104
Joined: Sat Aug 20, 2005 2:02 pm

Post by kool78 »

ray.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.
...
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...


thanks
"Attitude always and almost determines the altitude of your Life"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.

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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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.
Wasn't that what I quoted from the Developer's Guide? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Th3Und34D-
Participant
Posts: 10
Joined: Wed Feb 08, 2006 1:08 am
Location: Hyderabad

Post by Th3Und34D- »

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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Th3Und34D- wrote:I too faced similar problem.. I think it is due to the file FTP from windows to unix server.
Typically - yes. Or sometimes people map a UNIX drive in Windows and just drag and drop files. :roll:

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. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
smrutiranjannayak
Participant
Posts: 22
Joined: Mon Apr 02, 2007 4:02 am
Location: MUMBAI
Contact:

You can try this

Post by smrutiranjannayak »

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
:lol:
Smrutiranjan Nayak
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Investigate the Record Delimiter String property (rather than the Record Delimiter property). Specify as \r\n
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Th3Und34D-
Participant
Posts: 10
Joined: Wed Feb 08, 2006 1:08 am
Location: Hyderabad

Haaa... Finally i got a resolution for this.

Post by Th3Und34D- »

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
Post Reply