Escaping special characters - _ when doing COPY CSV - Mailing list pgsql-admin

From Edwin UY
Subject Escaping special characters - _ when doing COPY CSV
Date
Msg-id CA+wokJ9_q+81PFDH2NriJUZg8BjtBk=Z+ov4LRybmKAq70NBnA@mail.gmail.com
Whole thread Raw
Responses Re: Escaping special characters - _ when doing COPY CSV
List pgsql-admin
Hi,

I don't have access to run copy as this is a RDS database so I can only use \copy.
I need to send the output to csv.
One of the fields has a special character = \r. I can see it visually.

Running the \copy below gives me extra row/s because of the \r
\copy ( select *  from blah  where blah_ref = '666'   order by date_created desc  limit 5; ) to 'abc.csv' WITH CSV DELIMITER ',' HEADER

I have tried this
\copy ( select *  from blah  where blah_ref = '666'   order by date_created desc  limit 5; ) to 'abc.csv' WITH (FORMAT CSV, HEADER, ESCAPE '\r');

But it gives ERROR:  COPY escape must be a single one-byte character.

Besides using a view for the SQL, as suggested when I do a web search, any chance someone here knows how to do it without using a view?

Please advise. Thanks in advance.


Regards,
Ed

pgsql-admin by date:

Previous
From: Mauricio Fernandez
Date:
Subject: Re: Adding timestamp column
Next
From: Laurenz Albe
Date:
Subject: Re: Escaping special characters - _ when doing COPY CSV