diegobc11
diegobc11

Reputation: 97

COPY FROM in PostgreSQL, only selecting the first three columns with delimiter at the end

I have a data file that has values sepparated by '|' character like:

value1 | value2 | value3 |

COPY tableName FROM 'file.tbl' DELIMITER '|';

When I try to COPY these values into a table like the above statement it outputs the error:

ERROR: extra data after last expected column

This is because every line ends in a '|', I really don't want to create an extra column at the end unless strictly necessary because I have to this process for many tables. So one workaround that people suggest on other questions is to only COPY the first three columns of the file like:

COPY tableName (name, location, datetime) FROM 'file.tbl' DELIMITER '|';

but this outputs the same error as before.

ERROR: extra data after last expected column

Upvotes: 1

Views: 152

Answers (0)

Related Questions