public inbox for [email protected]  
help / color / mirror / Atom feed
Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
2+ messages / 2 participants
[nested] [flat]

* Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
@ 2025-07-11 12:20  gzh <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: gzh @ 2025-07-11 12:20 UTC (permalink / raw)
  To: [email protected]

Dear,


I am encountering an issue with the COPY command in PostgreSQL regarding the handling of line breaks in data fields. My PostgreSQL instance is installed on a Linux system.


When I use the COPY command to export data to a CSV file and then import the same CSV file back into the database, all carriage return characters (CR) in the fields are automatically converted to line feed characters (LF). For example:


Field content before import: *** (CR) ***
Field content after import: *** (LF) ***
I would like to know if there is a way to use the COPY command while preserving the original line breaks (CR) in the data fields during import.


Thank you for your assistance.


Best regards,
gzh

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Question Regarding COPY Command Handling of Line Breaks in PostgreSQL
@ 2025-07-11 13:07  Ron Johnson <[email protected]>
  parent: gzh <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Ron Johnson @ 2025-07-11 13:07 UTC (permalink / raw)
  To: pgsql-generallists.postgresql.org <[email protected]>

On Fri, Jul 11, 2025 at 8:20 AM gzh <[email protected]> wrote:

> Dear,
>
> I am encountering an issue with the COPY command in PostgreSQL regarding
> the handling of line breaks in data fields. My PostgreSQL instance is
> installed on a Linux system.
>
> When I use the COPY command to export data to a CSV file and then import
> the same CSV file back into the database, all carriage return characters
> (CR) in the fields are automatically converted to line feed characters
> (LF). For example:
>
> Field content before import: *** (CR) ***
> Field content after import: *** (LF) ***
> I would like to know if there is a way to use the COPY command while
> preserving the original line breaks (CR) in the data fields during import.
>

What PG version?
What's the full command (including both shell and SQL commands)?

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-07-11 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-11 12:20 Question Regarding COPY Command Handling of Line Breaks in PostgreSQL gzh <[email protected]>
2025-07-11 13:07 ` Ron Johnson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox