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 1m5X8i-000684-A7 for pgsql-general@arkaria.postgresql.org; Mon, 19 Jul 2021 17:33:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m5X8f-0004Sd-I8 for pgsql-general@arkaria.postgresql.org; Mon, 19 Jul 2021 17:33:09 +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 1m5X8f-0004SV-8r for pgsql-general@lists.postgresql.org; Mon, 19 Jul 2021 17:33:09 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5X8b-0001hI-6b for pgsql-general@lists.postgresql.org; Mon, 19 Jul 2021 17:33:08 +0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 747ED2A0107 for ; Mon, 19 Jul 2021 10:33:02 -0700 (PDT) Date: Mon, 19 Jul 2021 10:33:02 -0700 (PDT) From: Rich Shepard Reply-To: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Formating psql query output Message-ID: User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Until I finish building the python/tkinter/psycopg2 front end to my business tracking tool I continue to work using the psql shell.' I have a working .sql script that reports my contacts between two dates; the script returns more columns than I want included in the report. I want to pipe the output through an awk script to extract, in order, the columns I need. I'm stuck at the point of defining options to psql. The current command line is: psql -d bustrac -f prospecting_log.sql -o contacts.txt --csv However, using the --csv output conversion makes separate fields from a varchar column that can contain commas with the text contents. Without --csv I get normal psql output with column headings and separator lines such as these: person_nbr | act_date | act_type | notes | person_nbr | lname | fname | org_nbr | org_nbr | org_name ------------+------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------------------+------------+---------+---------+---------------------- Is there an option that will retain the '|' separator but exclude the headings? Reading the psql document page I don't see such an option. TIA, Rich