Re: The COPY command and csv files

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: "E(dot) Matthew Finnin" <emf(dot)storage(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: The COPY command and csv files
Date: 2006-04-18 10:50:40
Message-ID: C06A3CC0.9E19%sdavis2@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 4/18/06 3:06 AM, "E. Matthew Finnin" <emf(dot)storage(at)gmail(dot)com> wrote:

> Currently I have removed all double quotations from my null values
> ("na" has been changed to na). I have also removed the header line of
> the csv file I am trying to copy into the table. I have tried various
> forms of null values and everything else suggested to me, with no
> luck.
>
> Here are the table definitions. I was trying to make it as simple as
> possible:
> emf=> \d pwt61_oecd
> Table "public.pwt61_oecd"
> Column | Type | Modifiers
> ---------+---------+-----------
> country | text |
> isocode | text |
> year | numeric |
> pop | numeric |
> xrat | numeric |
> ppp | numeric |
> cgdp | numeric |
> cc | numeric |
> ci | numeric |
> cg | numeric |
> p | numeric |
> pc | numeric |
> pg | numeric |
> pi | numeric |
> openc | numeric |
> cgnp | numeric |
> csave | numeric |
> y | numeric |
> rgdpl | numeric |
> rgdpch | numeric |
> rgdpeqa | numeric |
> rgdpwok | numeric |
> rgdptt | numeric |
> openk | numeric |
> kc | numeric |
> kg | numeric |
> ki | numeric |
> grgdpch | numeric |
>
> This is the error I get after using the copy command:
> ERROR: missing data for column "isocode"
> CONTEXT: COPY pwt61_oecd, line 1:
>
> This is the first line of the csv file, where the error is occuring:
> "Australia","AUS","1950","8434.0650803","0.8931999704","0.515977685","1836.330
> 3946","60.365553134","27.690222887","7.9941116957","57.767319935","53.85343018
> 6","73.898773273","61.642604011","47.850011457",na,"31.64033517","95.021059091
> ","9113.8072046","9173.8190347","10576.40502","22078.709149","9988.2503259","1
> 9.331539711","65.924922543","13.104642709","26.200404435",na
>
> If I drop the column 'isocode' from the table and from the csv file, I
> receive the following error:
> ERROR: missing data for column "year"
> CONTEXT: COPY pwt61_test, line 1:
>
> Here the first line of the csv file is:
> "Australia","AUS","1950","8434.0650803","0.8931999704","0.515977685","1836.330
> 3946","60.365553134","27.690222887","7.9941116957","57.767319935","53.85343018
> 6","73.898773273","61.642604011","47.850011457",na,"31.64033517","95.021059091
> ","9113.8072046","9173.8190347","10576.40502","22078.709149","9988.2503259","1
> 9.331539711","65.924922543","13.104642709","26.200404435",na
>
> Notice the error has remained in the second column and it doesn't
> matter what value it holds or what the data type is.
>
> I am at a complete loss. Thank you again for your help.

What is the exact command that you are using to import the data?

Sean

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-04-18 14:02:09 Re: The COPY command and csv files
Previous Message Christoph Della Valle 2006-04-18 07:37:41 Re: PostgreSQL a slow DB?