"E. Matthew Finnin" <emf.storage@gmail.com> writes:
> 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.3303946","60.365553134","27.690222887","7.9941116957","57.767319935","53.853430186","73.898773273","61.642604011","47.850011457",na,"31.64033517","95.021059091","9113.8072046","9173.8190347","10576.40502","22078.709149","9988.2503259","19.331539711","65.924922543","13.104642709","26.200404435",na
Is that really exactly what the error message looks like? Because what
it should be echoing back after "line 1:" is the first line of the file.
Here's a trivial example using data entered from the keyboard:
regression=# create table t1 (f1 text,f2 text);
CREATE TABLE
regression=# copy t1 from stdin csv;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> "A","B"
>> \.
regression=# copy t1 from stdin csv;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> "A"
>> \.
ERROR: missing data for column "f2"
CONTEXT: COPY t1, line 1: ""A""
regression=# copy t1 from stdin csv;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>>
>> \.
ERROR: missing data for column "f2"
CONTEXT: COPY t1, line 1: ""
regression=#
I'm wondering if maybe you're making some simple mistake that's got
nothing to do with the file format, but rather you're pointing COPY
at the wrong file or some such. The behavior seems consistent with
the idea that COPY is seeing an empty line as the first line of data.
regards, tom lane