Import/Copy CSV/data to Postgres

I recently was having trouble importing CSV to postgres. The trouble was with empty trailing columns (the first row had an empty trailing column). I found that a tab delimited file (export from excel, using export as ms-dos text) allowed me to avoid warnings about empty columns.

was getting this error in postgres while trying to run the “COPY” command from sql:

WARNING: nonstandard use of escape in a string literal

This error was followed by a description of where the error was occuring, which was showing the error in the wrong place. To fix this issue, make sure that all slashes (such as in file paths) are “/” rather than “”

Here is an example of a proper COPY command:

COPY count_crime TO ‘c:/temp/temp.csv’ USING DELIMITERS ‘,’

Leave Comment