Re: ERROR: extra data after last expected column

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: scott macri <hacktorious(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ERROR: extra data after last expected column
Date: 2022-03-07 23:57:40
Message-ID: 095fbaeb-9c9e-1c8f-42bd-d1e75eb81eb5@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On 3/7/22 16:48, scott macri wrote:
>
>
> On Mon, Mar 7, 2022, 6:42 PM Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
>
> On 3/7/22 16:33, scott macri wrote:
>> No luck
> Bummer.  Best to bottom post or in-line comment on this forum.
>
>
>>
>> On Mon, Mar 7, 2022, 4:58 AM Rob Sargent <robjsargent(at)gmail(dot)com>
>> wrote:
>>
>> On 3/7/22 02:08, Sándor Daku wrote:
>>>
>>>
>>> On Mon, 7 Mar 2022 at 09:34, Scott Macri
>>> <Scott(at)bitsnbytes(dot)io> wrote:
>>>
>>> I'm trying to use the postgres copy command and getting,
>>> "extra data
>>> after last expected column".
>>>
>>> All items in the DB are currently set to varchar(255) to
>>> make it
>>> simple.  I've checked for hidden characters in the file
>>> and don't see
>>>
> Simpler yet is to make the columns "text"
>
>>> any.  All the other files I've processed with this exact
>>> command worked
>>> perfectly.  I've processed 10 other's so far.  The only
>>> difference I
>>> notice is this one has significantly more columns.
>>>
>>> The number of columns in the DB (25) exactly match the
>>> number of
>>> columns in the csv (25), which exactly match the number
>>> of columns
>>> defined in my COPY command (25). I've read practically
>>> every post on
>>> the internet over the last two days containg this error
>>> and cannot
>>> resolve it.  I am completely stumped at this point.
>>>
>>> It pukes after the 9th column every time no matter what
>>> I change.
>>>
>>> COPY
>>> option_details(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y)
>>> FROM '/home/dump/my_csv.csv' WITH (FORMAT CSV, DELIMITER
>>> '|', ENCODING
>>> 'UTF8');
>>>
> You've verified the encoding is UTF8?
>
>>> Row one data in file is below:
>>> item a | item b | item c | item d | item e | item f |
>>> item g | item h |
>>> item i | item j | item k | item l | item m | item n |
>>> item o | item p |
>>> item q | item r | item s | item t | item u | item v |
>>> item w | item x |
>>> item y
>>> --- Line two would normally start here but no reason to
>>> show since it's
>>> failing above. ---
>>>
>>> I get the following error:
>>> ERROR:  extra data after last expected column
>>> CONTEXT:  COPY option_details, line 1: "item a|item
>>> b|item c|item
>>> d|item e|item f|item g|item h|item i|..."
>>>
>>>
> Does line two generate the same error?
> Is there perhaps a funky line ending?
>
>
> Yes it does.
>
>
Can we see the live DDL of option_details table (i.e. from psql \d
option_details)?
Best to reply to  the list so we're all on the same page

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Macri 2022-03-08 01:40:54 Re: ERROR: extra data after last expected column
Previous Message Steve Midgley 2022-03-07 23:56:40 Re: ERROR: extra data after last expected column

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Macri 2022-03-08 01:40:54 Re: ERROR: extra data after last expected column
Previous Message Steve Midgley 2022-03-07 23:56:40 Re: ERROR: extra data after last expected column