Re: PGSQL 9.3.2 COPY command issues

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: PGSQL 9.3.2 COPY command issues
Date: 2014-07-18 12:15:07
Message-ID: 1405685707257-5811948.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

spake wrote
> Here is my psql command:
> COPY data FROM '/Developer/data_20140608.csv' DELIMITER ',' CSV HEADER;
>
> and here is the error I get:
> ERROR: invalid input syntax for type numeric: ""
> CONTEXT: COPY npi_data, line 2, column replacement_npi: ""

Numeric columns in CSV are not quoted. What you have here is a text field in
the file and a numeric field in the database. You must resolve the
mis-match. The easiest way is to define the table column as text. If you
ultimately need to convert the column into numeric then you should consider
the import table to be a staging table and after the copy is done you
migrate the copied in data to the production table while performing any data
transformations needed.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/PGSQL-9-3-2-COPY-command-issues-tp5811940p5811948.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message John Neal 2014-07-18 19:53:07 JBDC LDAP support
Previous Message Vinayak Pokale 2014-07-18 09:27:37 Re: PGSQL 9.3.2 COPY command issues