Steffen Bobek
Steffen Bobek

Reputation: 642

Postgres: How to use COPY FROM WITH DELIMITER with CHR function?

I try to import a text file into a single column table, i.e. I don't want a single line of the source file to be delimited into columns. The file contains many different characters (tabs, commas, spaces) that could be recognized as delimiters. Since bell (CHR(7)) doesn't exist in the data file I chose it as delimiter:

COPY data_table(single_column) FROM '/tmp/data' WITH ENCODING 'LATIN1' DELIMITER CHR(7);

Unfortunately, this results in an error:

ERROR: syntax error at or near "chr"

What would be the correct syntax?

Upvotes: 1

Views: 1334

Answers (1)

jjanes
jjanes

Reputation: 44227

You can't use a function there. Use the escape notation.

 DELIMITER E'\007'

Upvotes: 2

Related Questions