Problem with COPY FROM

Started by Jay O'Connoralmost 23 years ago3 messagesgeneral
Jump to latest
#1Jay O'Connor
joconnor@cybermesa.com

I'm trying to bulk load a table from a data file using a 'COPY FROM'
command.

I'm getting an error saying that there is "Extra data after last expected
column" (on the first line)

I'm using a full column list in the copy from:
COPY tablename (col1, col2, col3..)

and the number of columns matches the number of tab delimited fields in the
file, so my guess right now is that I'm not properly marking the end of
row. I've tride using carraig returns, line feeds, and even hust putting
in the strings "\n\r" at the end in various combinations.

So what is the proper way of ending a line in a file you expect to feed in
to "COPY FROM"...

Otherwise, I may have to post the full command and a snippet from the file
and hope someone can see something I'm missing

Thanks

Take care,
Jay

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jay O'Connor (#1)
Re: Problem with COPY FROM

"Jay O'Connor" <joconnor@cybermesa.com> writes:

So what is the proper way of ending a line in a file you expect to feed in
to "COPY FROM"...

Newline (\n). Don't put a tab after the last column, either.

regards, tom lane

#3Jay O'Connor
joconnor@cybermesa.com
In reply to: Tom Lane (#2)
Re: Problem with COPY FROM

On 2003.05.28 12:00 Tom Lane wrote:

"Jay O'Connor" <joconnor@cybermesa.com> writes:

So what is the proper way of ending a line in a file you expect to feed

in

to "COPY FROM"...

Don't put a tab after the last column, either.

*THAT* was the problem. My loop in my code of writing fields didn't check
for the last field and just added a tab after every field.

Thanks

Take care,
Jay