Running COPY results in ERROR: invalid input syntax for integer: \"\"
error message for me. What am I missing?
My /tmp/people.cs
ERROR: invalid input syntax for integer: ""
""
isn't a valid integer. PostgreSQL accepts unquoted blank fields as null by default in CSV, but ""
would be like writing:
SELECT ''::integer;
and fail for the same reason.
If you want to deal with CSV that has things like quoted empty strings for null integers, you'll need to feed it to PostgreSQL via a pre-processor that can neaten it up a bit. PostgreSQL's CSV input doesn't understand all the weird and wonderful possible abuses of CSV.
Options include:
csv
module, Perl Text::CSV
, etc to pre-process it;