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 1hiRpG-0005bD-4W for pgsql-general@arkaria.postgresql.org; Tue, 02 Jul 2019 23:04:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hiRpE-000485-O3 for pgsql-general@arkaria.postgresql.org; Tue, 02 Jul 2019 23:04:36 +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 1hiRpE-00047y-75 for pgsql-general@lists.postgresql.org; Tue, 02 Jul 2019 23:04:36 +0000 Received: from ook.raf.org ([139.99.156.21]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hiRpA-0005UJ-Ui for pgsql-general@lists.postgresql.org; Tue, 02 Jul 2019 23:04:34 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 7C1365DE74 for ; Wed, 3 Jul 2019 09:04:28 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y4BzlwiZpRcP for ; Wed, 3 Jul 2019 09:04:27 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id 7D0215DEB6; Wed, 3 Jul 2019 09:04:27 +1000 (AEST) Date: Wed, 3 Jul 2019 09:04:27 +1000 From: raf@raf.org To: pgsql-general@lists.postgresql.org Subject: Re: Message-ID: <20190702230427.sgmhd6wwf2j5mima@raf.org> References: <45312c734ff4177639b309940be4017d91f4a38b.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45312c734ff4177639b309940be4017d91f4a38b.camel@cybertec.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Laurenz Albe wrote: > On Tue, 2019-07-02 at 13:09 +0530, Prakash Ramakrishnan wrote: > > We are getting below error while during import the csv file please do the needful. > > I'd say the needful thing here is for you to read the documentation... > > > -bash-4.2$ more ckr_sto.csv > > 4937880 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128790679 | | | | > > 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | | > > 4939744 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128684510 | | | | > > 4939750 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128683100 | | | | > > 4936360 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128567527 | | | | > > 4940308 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128781329 | | | | > > 4938006 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 4000128912554 | | | | > > 4937457 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128426574 | | | | > > > > error > > ---------- > > postgres=# \copy ckr_sto from /data/ckr_sto.csv CSV HEADER; > > ERROR: invalid input syntax for integer: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 5000128639345 | | | | " > > CONTEXT: COPY ckr_sto, line 2, column pod_id: " 4939355 | 12 | 2015-01-05 | | 2015-01-05 05:51:47 | | | 500012863934..." > > >From the documentation of COPY: > > DELIMITER > > Specifies the character that separates columns within each row (line) of the file. > The default is a tab character in text format, a comma in CSV format. > This must be a single one-byte character. This option is not allowed when using binary format. > > Yours, > Laurenz Albe > -- > Cybertec | https://www.cybertec-postgresql.com in other words, ckr_sto.csv is not a csv file. it just has .csv at the end of its name. that's why psql tried to interpret the entire line as the first column: there were no commas. its contents should look something like: 4937880,12,2015-01-05,,2015-01-05 05:51:47,,,5000128790679,,,, 4939355,12,2015-01-05,,2015-01-05 05:51:47,,,5000128639345,,,, 4939744,12,2015-01-05,,2015-01-05 05:51:47,,,5000128684510,,,, 4939750,12,2015-01-05,,2015-01-05 05:51:47,,,5000128683100,,,, 4936360,12,2015-01-05,,2015-01-05 05:51:47,,,5000128567527,,,, 4940308,12,2015-01-05,,2015-01-05 05:51:47,,,5000128781329,,,, 4938006,12,2015-01-05,,2015-01-05 05:51:47,,,4000128912554,,,, 4937457,12,2015-01-05,,2015-01-05 05:51:47,,,5000128426574,,,,