From: | George Neuner <gneuner2(at)comcast(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | pgadmin - import a CSV with nulls? |
Date: | 2017-08-31 20:04:55 |
Message-ID: | ajogqc51jhsugs73fe5tijhmrdk9u6jd9g@4ax.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I'm trying to move some data between databases that have different
structure, and I'm stuck on how to import a CSV file that contains
nulls.
Both databases are remote, so COPY is not an option - I don't have
shell or filesystem access to the servers.
pgAdmin 4 seems useless: it neither lets me reorder exported columns,
nor does it allow me to write query results to a file. I really don't
want to have to create an import staging table with structure matching
the export [if that even would work] because there are a number of
tables involved and quite a lot of data to be moved.
pgAdmin 3 lets me write query results to a file, but I can't figure
out how to import null values back in. The only option for specifying
nulls in CSV appears to be "" (empty string), but import chokes on
that.
I have seen posts on stackoverflow advising: e.g., to "edit the CSV
file to change nulls to \N and specify '\N' in the import options".
But this doesn't appear to work with pgAdmin 3.
I have tried using the empty field (e.g., blah,,blah ), the empty
strings '' and "", and every permutation of \N, '\N', and "\N". I've
been at this for a couple of hours now and I can't find a solution
that works. No matter what I try I get "invalid input syntax for type
..." when import hits the first null value.
Does anyone know a way to do this reliably?
Thanks,
George
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-08-31 20:20:27 | Re: pgadmin - import a CSV with nulls? |
Previous Message | Melvin Davidson | 2017-08-31 15:46:24 | Re: Table create time |