Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nRWlR-0004tq-C7 for pgsql-sql@arkaria.postgresql.org; Tue, 08 Mar 2022 10:08:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nRWlP-0008TI-7F for pgsql-sql@arkaria.postgresql.org; Tue, 08 Mar 2022 10:08:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nROqS-0004zp-Sc for pgsql-sql@lists.postgresql.org; Tue, 08 Mar 2022 01:41:00 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nROqQ-0007YU-EX for pgsql-sql@lists.postgresql.org; Tue, 08 Mar 2022 01:41:00 +0000 Received: by mail-qt1-x82e.google.com with SMTP id bt3so14998929qtb.0 for ; Mon, 07 Mar 2022 17:40:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:message-id:subject:reply-to:to:cc:date:in-reply-to :references:organization:user-agent:mime-version :content-transfer-encoding; bh=hR+HQad+qO5L6ojaQ0oRQdOcfcadg75OPO+98KgZjzs=; b=UxU/TXUChHoPrFy36tP+RrynTSLD+74Nf6MHvu5HUHGzJFLa5m47lO2nc5CPoKrJTa /xMA4+FGLzc7uYBcNRcNPNbFPRLwuqJpDJQ97OT7YMil+G+8tIc+Nn8a0DbQ3hE69TWt b7aDKcfvnuk1Cr4/1Ka04U9+cglELC0s//I8cb26mBKJFxhyFDRsIYfNs3hRB3eR7sjE 5NqNPSPjNYYIZ9EJEFXN4qURykp0asLT+tSQslVjk9Es/1Ho9+fxfatNipXvaPNhBjSX F2EFphqo9AGn7jUqHiHRPz6slpQbn3TeR5I2qvVjmn3ZuDb1W5tV1NAXkrrwQBzLW9rj KF6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:message-id:subject:reply-to:to:cc :date:in-reply-to:references:organization:user-agent:mime-version :content-transfer-encoding; bh=hR+HQad+qO5L6ojaQ0oRQdOcfcadg75OPO+98KgZjzs=; b=3b9NUd7ieQoV/t0V9yFlE1DXHzYipdXXDBBGBUgfH0KoY1ebHE22zoL+B8AZicyeLr 3AW9/flzBXfH6diAD4WDxGoGhCUlHN3Qu066Oyt7yiz+H/MhTGN18aLQSqEAOpyyShdR lZJr4o8k1xg5vtvYifB27iHi99c4UDtQCoTdzcQCKWWe0I2682LU+Oy3ysOUWTVEL7tx ra0JuaVvjWpcdg6FGCyLNN7G03l0VFATtB8vIaVVAkYNuFlPXJat/jSlsbUs2WDhFsm3 DY5m5QKNIejU7MAc7zsDhoxhdVvbArYqm7hSQMn7EKO+K+aJFLJAKjsvekhDaLls1GFZ UrTw== X-Gm-Message-State: AOAM532FbQE2hwmw8ym3TShF1jn3F6jBDE+AMnpYWJkDOyy9DMgsf4hK DwW3EemgKMISeiNuTrO4R7U= X-Google-Smtp-Source: ABdhPJy2w7nhhm9ueYiklvWS7FDm5hDArMEYKCoFY48+cK6X4YHteU+76jO2K6mfCy5dyhF6wcAAQQ== X-Received: by 2002:ac8:7e87:0:b0:2e0:5e20:5fe9 with SMTP id w7-20020ac87e87000000b002e05e205fe9mr10484627qtj.382.1646703656574; Mon, 07 Mar 2022 17:40:56 -0800 (PST) Received: from [10.132.0.6] ([45.132.227.243]) by smtp.gmail.com with ESMTPSA id f7-20020a05622a104700b002d4b318692esm9637480qte.31.2022.03.07.17.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 17:40:56 -0800 (PST) Sender: Scott Macri From: Scott Macri X-Google-Original-From: Scott Macri Message-ID: <40a8c68234081f39c07c7ec300e96797ca6fa55b.camel@gmail.com> Subject: Re: ERROR: extra data after last expected column Reply-To: Scott@BITSnBYTES.io To: Steve Midgley Cc: Rob Sargent , pgsql-sql Date: Mon, 07 Mar 2022 20:40:54 -0500 In-Reply-To: References: <775429fc5428ca2640f72f1d29f6e8ec90955e6c.camel@gmail.com> Organization: BITSnBYTES Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (by Flathub.org)) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2022-03-07 at 15:56 -0800, Steve Midgley wrote: > > > On Mon, Mar 7, 2022 at 3:54 PM Steve Midgley > wrote: > > > > On Mon, Mar 7, 2022 at 3:34 PM scott macri > > wrote: > > > No luck > > > > > > On Mon, Mar 7, 2022, 4:58 AM Rob Sargent > > > wrote: > > > > On 3/7/22 02:08, Sándor Daku wrote: > > > >   > > > > > > > > > >   > > > > > On Mon, 7 Mar 2022 at 09:34, Scott Macri > > > > > 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 > > > > > >  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'); > > > > > >   > > > > > >  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|..." > > > > > >   > > > > > >   > > > > > >  Any help or advice would be greatly appreciated.  Thank > > > > > > you very much. > > > > > >   > > > > > >  -- > > > > > >  Hacktorious > > > > > >   > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > I pretty sure it doesn't fail after the  9th column, just the > > > > > context hint of the error message is cropped after that. > > > > > My guess is a sneaky '|' somewhere inside one of your field. > > > > > > > > > > Regards, > > > > > Sándor  > > > >  if Sándor  is correct this will show the offenders > > > >  awk -F "|" '{if (NF != 25) print}' > > > >   > > > >   > > > > > > > > > Can you send the CSV file that is causing the problem as a CSV file > > attachment so some of us can try this as a full reproduction? I > > don't want to copy/paste the sample line from the text of the email > > as it seems like that wouldn't be a good replication path for such > > a weird bug.. > > > > > > > Also, have you tried ASCII encoding or something very permissive like > that? If that works but UTF-8 doesn't, it might be a clue that > there's an errant char buried in your CSV file. Also, maybe try > looking at your CSV file with a hex editor.. The weirdest stuff can > turn up in "wild caught" CSVs..  So I guess when I ran:  awk -F "|" '{if (NF != 25) print}' the first time it was against the wrong file. I just tried again and it produced a bunch of output. So this is telling me there are extra '|' in those lines? -- Hacktorious