Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZD2f-0005fp-Bc for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2019 11:28:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hZD2d-0002vI-9w for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2019 11:28:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZCzK-0002DT-MR for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2019 11:24:50 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZCzH-0006SG-SD for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2019 11:24:49 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id x7so653169ybg.5 for ; Fri, 07 Jun 2019 04:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=mhPCOlFwA8kswxGuFB9GnnamjbIQwCjb5DZ240f1LaE=; b=Je9af7Erlv8tB0Q3dwiuErubc2okwuXKct/xAJerM/V2/gBXiaB4uIXpzBcotrWXPI iPP7NPBTlG+NSQbTw9M3eWy8CQ5FSbsG9yAYqmOUe5gbRiGZZ1/z2GBlS8m8gOL7t0dB QCuoniMoBh0pWlLOX7a68axpWVoAboFddNJZtuoQ4wv1/eUKHsCMEBRdCYToGPdwPIG0 UVZQFFRaCFPv/urEeYHnhRmJzUNW6N9nMz4ZyMKSfGLfgUfGcmm2hC3jF2qgLQSkqPCj L6BImRrt0zc99vdb8ZskqcPyqR+p8OrXxYo9yjBUSUUH6hPShwbNASlXcVA+au9FDLEx fDPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=mhPCOlFwA8kswxGuFB9GnnamjbIQwCjb5DZ240f1LaE=; b=gidIvIYsQV19nZ0NNI1JLR3M2mCs9jpzGVrnNK33LUGUInRKzqFE1cuDom+i4hKgG0 Aw9SjDYWuNaAVYV2iQpERuK4eBV6l7tJC0rA5FqhzXtBebR7TN90CVvJOym0JEjHPZO9 NfcKXDBHrXdX45BprA4dQIi6L5OWIrYurVpAHM7L/2LW1qgbObCJr9QrSN0S4ohX6Y+5 b1XZ/+AcK16a3xyi3n2fAwJ2ApheV2/fh8yL2X1nhVaDr5BHe8BceOaz/T+jU6fWY/rq 8sahiNtpcibkvgMOjvN4x9JnTcRWovF2oyiiF7DWHIcLf5049XQMnwAj1mzT+C5v+e8C Djug== X-Gm-Message-State: APjAAAXHZ8w20ejUHMSddcnOjY6tTboVopXxSr6g2zTmk+UjTMBVGquh vGSwg6fbUKlMg7Elp2SJK2Xfy+cazxs= X-Google-Smtp-Source: APXvYqzN4EOxctojUDkOusTu7F4yvsE+xbkJz8dUF1qgDysSlnkmAaX2WZnoMNVtjaLWYoiqvrujyQ== X-Received: by 2002:a25:7444:: with SMTP id p65mr24123909ybc.319.1559906686804; Fri, 07 Jun 2019 04:24:46 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id 13sm489725ywm.38.2019.06.07.04.24.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 04:24:46 -0700 (PDT) Subject: Re: delimeters psql /CSV To: pgsql-general@lists.postgresql.org References: <785199B14156764C8EB14EF96CEDC44EE041CA@xw-exch03.lfv.se> From: Ron Message-ID: Date: Fri, 7 Jun 2019 06:24:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <785199B14156764C8EB14EF96CEDC44EE041CA@xw-exch03.lfv.se> Content-Type: multipart/alternative; boundary="------------4A5580135B25152E0CEC930F" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------4A5580135B25152E0CEC930F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 6/7/19 5:01 AM, paul.malm@lfv.se wrote: > > Hi, I have a problem with psql and CSV. > > C:\Users\an\bin>C:\Tmp\psql -h 10.211.43.22 -p 5432 -U postgres -d aatest > -w  -c  "\copy public.""Bayern"" FROM 'C:\Users\an\test\Bayern.csv' WITH > DELIMITER ';' CSV" > > Error:  extra data after expected last column > > CONTEXT:  COPY Bayern, row 1: > "48.455555555555556;11.800833333333333;Anglberg/Amper;Industrial > plant;722;220;220;2133;0;0;Undefined..." > > I have a table (Bayern) with all columns in the right format. There is a > column-value which has a ‘/’ in the string (Anglberg/Amper). I think that > ‘/’ is taken for a delimeter, since when I replace / with ‘white space‘ it > works. > > I use ‘;’ as delimeter. I have UTF-8 encoding in the db. Is there a way > around this or do I have to go through all csv files and change ‘/’ to > white space? > What if you escape the slashes with backslashes? -- Angular momentum makes the world go 'round. --------------4A5580135B25152E0CEC930F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 6/7/19 5:01 AM, paul.malm@lfv.se wrote:

Hi, I have a problem with psql and CSV.

 

C:\Users\an\bin>C:\Tmp\psql -h 10.211.43.22 -p 5432 -U postgres -d aatest -w  -c  "\copy public.""Bayern"" FROM 'C:\Users\an\test\Bayern.csv' WITH DELIMITER ';' CSV"

Error:  extra data after expected last column

CONTEXT:  COPY Bayern, row 1: "48.455555555555556;11.800833333333333;Anglberg/Amper;Industrial plant;722;220;220;2133;0;0;Undefined..."

 

I have a table (Bayern) with all columns in the right format. There is a column-value which has a ‘/’ in the string (Anglberg/Amper). I think that ‘/’ is taken for a delimeter, since when I replace / with ‘white space‘ it works.

I use ‘;’ as delimeter. I have UTF-8 encoding in the db. Is there a way around this or do I have to go through all csv files and change ‘/’ to white space?


What if you escape the slashes with backslashes?

--
Angular momentum makes the world go 'round.
--------------4A5580135B25152E0CEC930F--