Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d9D6E-0004no-IK for pgsql-admin@arkaria.postgresql.org; Fri, 12 May 2017 16:07:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d9D6E-0004rk-5G for pgsql-admin@arkaria.postgresql.org; Fri, 12 May 2017 16:07:26 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d9D6D-0004qE-0b; Fri, 12 May 2017 16:07:25 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d9D6A-0006xS-20; Fri, 12 May 2017 16:07:23 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5868320BA1; Fri, 12 May 2017 12:07:21 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Fri, 12 May 2017 12:07:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=OodFMwQw+swAF7PtT5 nt9BWtYxXBXYvWuSCaZDnau2U=; b=bi71DQsMT7n9g6kbHgXjo73YmWLmfzuriz Ym1l9EgIEfnqgDoHcbohOq7PGFCYfqFu6RledXFp4W/985wWf2AY0ajv0gj7rFHG YFGXtr8amvpZCxP+aDRlGfziBEQcAxAcMJMRx0tT6Xo0vALov1mmcG0MLExxeF27 NLPkl+UaWzYxz0P/QP+1+DOCYaNXgtwfbZRR+MJI4weku5WIIsi6LowdCsY2HKrT Slcts+MAp03J8B551W5l95D0yO8z44mtgYZ222hM0ik/8CVHOB5HL26D6BbvoT0g lvJw1bP0Gl7li0PgTJTqo6v/geywFyyXLmaGH3wTm1UHecc794pA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=OodFMwQw+swAF7PtT5nt9BWtYxXBXYvWuSCaZDnau2U=; b=mEYhWnpP MwWQZ+H+IhBT6Ud8ioz0pZ+7RFe+Sumh5QEduE30uNykWXe1QfIPNHz0pWRc16tU Ni2HNyKG2lNCTHuD0zQs279iMUg8RT5VcLOCPy9BFsBiOU1zJAAL2fKlMe8JmlqO 1Rv8/bmvzyRJQzrTvCeXRKgi0LNzF46Oyx2Mp2+/2VuTUwXh5tkzYRNTAZ8789oL Wr8usS+/uiRJ1kkNkRkndyTKra0YQTCGKghMZ9+oK2QG25R91tzzAEGpearRoeGA GVImFGCH856n0FgqnG1OWu7tDqZXVJBbWClTrjJn7blOtODCQwtmWM1T4ZkITFcv Pu4B13T+tUpiSg== X-ME-Sender: X-Sasl-enc: b+HSorWtpViTY1wj05+3YEPGH9aR6UQEioq7n4fe7BNY 1494605241 Received: from ranger.suse (97-113-39-200.tukw.qwest.net [97.113.39.200]) by mail.messagingengine.com (Postfix) with ESMTPA id BCFE624951; Fri, 12 May 2017 12:07:20 -0400 (EDT) Subject: Re: [SQL] exporting query result To: =?UTF-8?Q?G=c3=bcnce_Kaya?= , pgsql-admin@postgresql.org, pgsql-sql@postgresql.org References: <4498cd4b-95b7-c4f5-add4-b6555267296a@aklaver.com> From: Adrian Klaver Message-ID: <3d7d9782-0123-6d28-a661-a008ba3024e9@aklaver.com> Date: Fri, 12 May 2017 09:07:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org On 05/12/2017 08:58 AM, Günce Kaya wrote: > Hello, > > Thank you for your advice. But I did not want to ask about using Copy. I > always use it but my requirement is if there is anyway to export query > result to CSV's different sheets. CSV != spreadsheet. You can export to CSV using COPY or \copy in psql and then import those into a spreadsheet. If you want something that creates an xls(x) file directly then that is going to require a third party software. I use Python for doing stuff like that. Some programs I use are: Pandas http://pandas.pydata.org/pandas-docs/stable/io.html XlsxWriter http://xlsxwriter.readthedocs.io/ csvkit http://csvkit.readthedocs.io/en/1.0.2/ FYI, csvkit is a collection of command line tools, so it just needs Python to be installed. > > Regards, > Gunce Kaya > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin