skip to Main Content

Running into an issue with copying the following data into a DB

1, ab"c

I receive an unterminated quote error when running the following SQL

copy table_name from sample.tsv CSV DELIMITER ',' QUOTE '"' ESCAPE E'\'

Based on the postgresql documentation I expect the escape parameter to be used to escape the quotation character but it’s not working. Would like to see if there’s a solution to this issue without reformatting the data, or changing the quote character.

2

Answers


  1. try this. Because if quote is ", then it will mix with double quote in (ab"c).

    copy table_name from 'sample.tsv' (FORMAT CSV, QUOTE '''', DELIMITER ',',ESCAPE E'\');
    
    Login or Signup to reply.
  2. It is expecting to find escaped quotes only inside quotes, so the command you show would work for 1,"ab"c" but not for what you have.

    The command that would work for the data you show is:

    copy table_name from sample.tsv DELIMITER ','
    

    But it is not likely to work for the rest of your data.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search