Failed import of date using COPY
If I use '""' as NULL, I get:


I get these issues all the time. PostgreSQL has made a really massive and stupid mistake from a UI perspective by having two modes


CSV
NON-CSV


CSV according to them is RFC4180. However, it's not all that useful to adhere to a spec if no one else does and RFC4180 is probably the least used spec on the internet. Start using it people.

Anyway to solve these problems the easy method is to create a test table...

CREATE TABLE foo ( x int, y int, z int );
INSERT INTO foo (x,y,z) VALUES (1,null,2);


And then to get to work brute forcing options for both modes. That's why I do anyway because I find it so unintuitive. It's pretty quick though.

COPY foo TO STDOUT NULL AS '""' DELIMITER ',';


That seems to do what you want. You should be able to read it with the same options.

COPY foo FROM '/tmp/test.csv' NULL AS '""' DELIMITER ',';