0
votes

I want to copy a Postgres (version 11) table into a csv file with delimiter as double byte character. Please assist if this can be achieved.

I am trying this:

COPY "Tab1" TO 'C:\Folder\Tempfile.csv' with (delimiter E'অ');

Getting an error:

COPY delimiter must be a single one-byte character

1
I would suggest that you first copy to a temporary file with a safe single-byte character delimiter (BS \x08 is a good candidate) and then post-process it using your language of choice into 'C:\Folder\Tempfile.csv' by replacing BS with your double-byte delimiter. - Stefanov.sm

1 Answers

0
votes

You could use COPY TO PROGRAM. On Unix system that could look like

COPY "Tabl" TO PROGRAM 'sed -e ''s/|/অ/g'' > /outfile.csv' (FORMAT 'csv', delimiter '|');

Choose a delimiter that does not occur in the data. On Windows, perhaps you can write a Powershell command that translates the characters.