Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping backslash for outfile

Status
Not open for further replies.

nabana2

Technical User
Sep 26, 2005
21
ZA
Hi

I am inserting windows newline charachers into a field with the intention that when i "select into outfile" the field data will be written on several newlines.

It seems problem is that the default behaviour is to escape
the backslashes when writing the outfile so i end up with the literal charachers in the outfile.

example:
Field1
------
data\r\nmore data\r\nsome more data
------

mysql> select Field1 into outfile "test.txt" from Table;

returns:
data\\r\\nmore data\\r\\nsome more data

instead of:
data
more data
some more data

i have played with the "FIELDS ESCAPED BY '\\'" option with no luck.

Can this be done?
Or is there a better way?

Thanks

Windows xp
mysql 5.0
 
its the lines terminated by that you need.
SELECT blah
INTO outfile '/path/file' fields enclosed by '"' terminated by ',' lines terminated by '\n'
FROM table;

just play with that and see how it goes :)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
That behaviour is deliberate, so that it will be obvious that the newline is an embedded character, not a record separator.
All I can suggest is that you process the output with program code, deleting the backslashes.
 
thanks Tony.
I suspected as much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top