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 1kiDnt-00019T-GA for pgsql-admin@arkaria.postgresql.org; Thu, 26 Nov 2020 09:43:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kiDns-0005gk-9G for pgsql-admin@arkaria.postgresql.org; Thu, 26 Nov 2020 09:43:04 +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 1kiDns-0005gd-2L for pgsql-admin@lists.postgresql.org; Thu, 26 Nov 2020 09:43:04 +0000 Received: from jakobs.com ([85.214.83.89] helo=rs.plausibolo.de) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kiDnl-0003UO-B2 for pgsql-admin@lists.postgresql.org; Thu, 26 Nov 2020 09:43:03 +0000 Received: from localhost (localhost [127.0.0.1]) by rs.plausibolo.de (Postfix) with ESMTP id E96EE38037E; Thu, 26 Nov 2020 10:42:55 +0100 (CET) Received: from rs.plausibolo.de ([IPv6:::1]) by localhost (h2367442.stratoserver.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id VKOdRy0tktFg; Thu, 26 Nov 2020 10:42:55 +0100 (CET) Received: from [192.168.178.86] (p5b249d69.dip0.t-ipconnect.de [91.36.157.105]) by rs.plausibolo.de (Postfix) with ESMTPSA id 516A3380150; Thu, 26 Nov 2020 10:42:55 +0100 (CET) Subject: Re: Conditional query with copy command To: pgsql-admin@lists.postgresql.org References: From: Holger Jakobs Message-ID: Date: Thu, 26 Nov 2020 10:42:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sm6bYG3do3QGnXmZu1BmX0VBHZmWrEIjf" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --sm6bYG3do3QGnXmZu1BmX0VBHZmWrEIjf Content-Type: multipart/mixed; boundary="9sLHVSqmosRz7hycAg0Xyy19Hit77h7j4"; protected-headers="v1" From: Holger Jakobs To: pgsql-admin@lists.postgresql.org Message-ID: Subject: Re: Conditional query with copy command References: In-Reply-To: --9sLHVSqmosRz7hycAg0Xyy19Hit77h7j4 Content-Type: multipart/alternative; boundary="------------4097CC031FD0D1B733F098E7" Content-Language: de-DE This is a multi-part message in MIME format. --------------4097CC031FD0D1B733F098E7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi, Use the new syntax as of PostgreSQL 9.0: copy hk_card_master_test from=20 'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' (format=20 csv, header, encoding 'ISO_8859_5') where card_status =3D 'A' This allows a simple WHERE condition as shown. Am 26.11.20 um 09:27 schrieb Sachin Kumar: > Hi Experts, > > I am uploading 10 million data using CSV, but I want to put a=20 > condition on a column (Card_Status) inside=C2=A0the CSV that only where= =20 > Card_Status =3D A data should be uploaded rest data are not uploaded. > Please guide me in modifying the query I am using to upload the data > Query:- > copy hk_card_master_test from=20 > 'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' with=20 > delimiter ',' csv header encoding 'ISO_8859_5' > > --=20 > > Best Regards, > Sachin Kumar --=20 Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012 --------------4097CC031FD0D1B733F098E7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Hi,

Use the new syntax as of PostgreSQL 9.0:

copy hk_card_master_test from 'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' (format csv, header, encoding 'ISO_8859_5') where card_status =3D 'A'

This allows a simple WHERE condition as shown.


Am 26.11.20 um 09:27 schrieb Sachin Kumar:
Hi Experts,

I am uploading 10 million data using CSV, but I want to put a condition on a column (Card_Status) inside=C2=A0the CSV that = only where Card_Status =3D A data should be uploaded rest data are not uploaded.
Please guide me in modifying the query I am using to upload the data
Query:-=C2=A0
copy hk_card_master_test from 'C:/inetpub/wwwroot/cards/media/static/gc_card_master2L.csv' with delimiter ',' csv header encoding 'ISO_8859_5'

--

Best Regards,
Sachin Kumar
--=20
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
--------------4097CC031FD0D1B733F098E7-- --9sLHVSqmosRz7hycAg0Xyy19Hit77h7j4-- --sm6bYG3do3QGnXmZu1BmX0VBHZmWrEIjf Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wmMEABEIACMWIQScuJCxWJK1p5BOebGKV5yTsxlhugUCX794mQUDAAAAAAAKCRCKV5yTsxlhuiIz AKDcQ93nnLwAmF4798eDWNvvZF/eFwCfXFDuG0F9zy8yae+kuyWW5IcH9LA= =2VoW -----END PGP SIGNATURE----- --sm6bYG3do3QGnXmZu1BmX0VBHZmWrEIjf--