I have a CSV that contains various columns. One of the columns contains integer data. However, when running a copy to:
COPY soc
FROM '~/soc.asc'
WITH DELIMITER '$';
I'm getting the following:
ERROR: invalid input syntax for integer: ""
CONTEXT: COPY soc, line 1, column soc_code: ""
as it appears that Postgres is trying to stick an empty string in an integer. How can I fix this? I don't really want to fudge my schema to suit the import if it can be helped.
You can tell postgres to interpret some value as NULL, for example:
COPY soc FROM '~/soc.asc' WITH DELIMITER AS '$' NULL AS ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With