Обсуждение: [GENERAL] pgadmin - import a CSV with nulls?
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
Does anyone know a way to do this reliably?
The psql "\copy" meta-command should be capable of doing what you desire.
David J.
On Thu, 31 Aug 2017 13:20:27 -0700, "David G. Johnston" <david.g.johnston@gmail.com> wrote: >On Thu, Aug 31, 2017 at 1:04 PM, George Neuner <gneuner2@comcast.net> wrote: > >> Does anyone know a way to do this reliably? > >?The psql "\copy" meta-command should be capable of doing what you desire. > >David J.? I wasn't aware that psql could copy remotely. That worked perfectly - thank you very much!!! George