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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| ||||
| 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 |