Unix Technical Forum

^M characters in database

This is a discussion on ^M characters in database within the Informix forums, part of the Database Server Software category; --> I need to unload & reload a table, but one of the fields contains ^M characters, and this causes ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 11:44 AM
Dirk Moolman
 
Posts: n/a
Default ^M characters in database

I need to unload & reload a table, but one of the fields contains ^M
characters, and this causes the lines in the unload files to split into
separate lines.

How can I remove these characters from the table, before unloading it.
I started writing a 4GL program to try and do this, but so far I haven't
been able to get it to work.


The piece of code I am using to try and clean the column:


for i = 1 to length(variable)
if variable[i] != ascii(13) and
variable[i] != ascii(10) then
let newstring = newstring,variable[i]
end if
end for


Any ideas ?







Dirk Moolman
Database and Unix Administrator
Digicare Technologies (HealthCorp)



The other day I was trapped on an escalator for hours....the power went
out!!!


>

The information on this e-mail including any attachments relates to the official business of DigiCare (Pty) Ltd. The information is confidential and legally privileged and is intended solely for the addressee. Access to this e-mail by anyone else is unauthorised and as such any disclosure, copying, distribution or any action taken or omitted in reliance on it is unlawful. Please notify the sender immediately if it has inadvertently reached you and do not read, disclose or use the content in any way.
>

No responsibility whatsoever is accepted by DigiCare (Pty) Ltd if the information is, for whatever reason, corrupted or does not reach its intended destination. The views expressed in this e-mail are the views of the individual sender and should in no way be construed as the views of DigiCare (Pty)Ltd, except where the sender has specifically stated them to be the views of DigiCare (Pty) Ltd.
>

http://196.33.167.71/digicare

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 11:44 AM
Richard Harnden
 
Posts: n/a
Default Re: ^M characters in database

Dirk Moolman wrote:
> I need to unload & reload a table, but one of the fields contains ^M
> characters, and this causes the lines in the unload files to split into
> separate lines.
>
> How can I remove these characters from the table, before unloading it.
> I started writing a 4GL program to try and do this, but so far I haven't
> been able to get it to work.
>
>
> The piece of code I am using to try and clean the column:
>
>
> for i = 1 to length(variable)
> if variable[i] != ascii(13) and
> variable[i] != ascii(10) then
> let newstring = newstring,variable[i]


let newstring = newstring clipped, variable[i]

> end if
> end for
>
>
> Any ideas ?
>


Do you really want to strip then ^Ms?
Your data might look better if you replace them with spaces.

--
rh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 11:44 AM
Carsten Haese
 
Posts: n/a
Default Re: ^M characters in database

On Fri, 2006-08-04 at 07:57, Richard Harnden wrote:
> Dirk Moolman wrote:
> > I need to unload & reload a table, but one of the fields contains ^M
> > characters, and this causes the lines in the unload files to split into
> > separate lines.
> >
> > How can I remove these characters from the table, before unloading it.
> > I started writing a 4GL program to try and do this, but so far I haven't
> > been able to get it to work.
> >
> >
> > The piece of code I am using to try and clean the column:
> >
> >
> > for i = 1 to length(variable)
> > if variable[i] != ascii(13) and
> > variable[i] != ascii(10) then
> > let newstring = newstring,variable[i]

>
> let newstring = newstring clipped, variable[i]


That's going to eat any spaces that are present in the original string.

If you insist on using I4GL, you'll have to do something along the lines
of this:

let j = 0
for i = 1 to length(variable)
if variable[i] != ascii(13) and variable[i] != ascii(10) then
let j = j + 1
let newstring[j] = variable[i]
end if
end for

You could also use one of several free/libre programming languages that
allow access to Informix databases, such as PHP, Perl, or Python. They
all have more powerful string processing capabilities than I4GL. For
example, the above chunk of I4GL code translates into Python as the
one-liner

newstring = variable.replace('\r','').replace('\n','')

Best regards,

--
Carsten Haese | Phone: (419) 861-3331
Software Engineer | Direct Line: (419) 794-2531
Unique Systems, Inc. | FAX: (419) 893-2840
1687 Woodlands Drive | Cell: (419) 343-7045
Maumee, OH 43537 | Email: carsten@uniqsys.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:28 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com