I'm copying a CSV file into Postgres using SQL commands, and the file has two different possibilities for what I'd like to treat as null. The first is just a blank (two sequential commas). The second is the string "PrivacySuppressed".
I've tried importing the CSV like this:
COPY c2c.field FROM 'my_csv.csv' NULL AS 'PrivacySuppressed' HEADER csv;
The problem here is that although PrivacySuppressed is converted to null, the blank is treated as a blank string, and I get the following error:
ERROR: invalid input syntax for type integer: ""
How can you import a CSV like this that has multiple NULL possibilities? I could modify the original CSV by just stripping out the PrivacySuppressed string, but I'd like to keep this in the data (so that if we decide to change the application we'll still have access to it).
NULLstring. I would use that for the,,case. Then after the import use NULLIF to convert the'PrivacySuppressed'intoNULLs.