2

I'm trying to import data from a pipe-delimited text file into my Postgres data_master table. My command looks like this:

COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' 
    WITH FORMAT csv, 
    DELIMITER '|', 
    HEADER TRUE;

Here's the error:

temp=# COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' WITH FORMAT csv, DELIMITER '|', HEADER TRUE;
ERROR:  syntax error at or near "FORMAT"
LINE 1: .../me/Documents/DATA/39079.txt' WITH FORMAT csv...
                                              ^
temp=# show server_version;
-[ RECORD 1 ]--+-----
server_version | 10.1

From the docs this seems like a valid syntax for the command. What did I do wrong?

EDIT: I tried this after removing the commas as well, with the same results:

temp=# COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' WITH FORMAT CSV DELIMITER '|' HEADER TRUE;
ERROR:  syntax error at or near "FORMAT"
LINE 1: .../me/Documents/DATA/39079.txt' WITH FORMAT CSV...
                                              ^

1 Answer 1

2

The syntax following WITH should be in parentheses.

COPY data_master FROM '/Users/me/Documents/DATA/39079.txt' 
  WITH (
    FORMAT csv, 
    DELIMITER '|', 
    HEADER TRUE
  );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.