Re: Setting the Field Separator in PSQL

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "Osborn, Marty" <marty(dot)osborn(at)rsa(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Setting the Field Separator in PSQL
Date: 2015-04-07 21:57:02
Message-ID: 552452AE.3060302@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 04/07/2015 02:52 PM, David G. Johnston wrote:
> On Tue, Apr 7, 2015 at 2:48 PM, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>wrote:
>
> On Tue, Apr 7, 2015 at 1:39 PM, Osborn, Marty <marty(dot)osborn(at)rsa(dot)com
> <mailto:marty(dot)osborn(at)rsa(dot)com>>wrote:
>
> I need to change the field separator to a tab in an input SQL
> file.____
>
> __ __
>
> I’ve tried every combination of tab, ‘\t’, “\t”,
> --field-separator=’\t’, etc, etc.____
>
> __ __
>
> Should it be in the command line or in the SQL file?____
>
> ____
>
> Any help?____
>
>
>
> ​More context would helpful but keep in mind that within SQL the
> expression:
>
> '\t' is a literal back-slash and a literal "t"
>
> E'\t' is escaped to mean <tab>​
>
> Dealing with the shell complicates the issue so if you can avoid it
> I suggest that do avoid it.
>
>
> ​I should probably have tried my own advice first, and I still haven't,
> but the documentation states:
>
> "​"""
> fieldsep
> Specifies the field separator to be used in unaligned output format.
> That way one can create, for example, tab- or comma-separated output,
> which other programs might prefer. To set a tab as field separator, type
> \pset fieldsep '\t'. The default field separator is '|' (a vertical bar).
> ​"""​
>
> ​So I'm not sure if this report is user-error or documentation error. A
> self-contained test case would help...

Well the OP was talking about an input file, so I my suspicion they are
looking for something like \copy.

>
> David J.​
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rishi Ranjan 2015-04-14 10:39:38 pgsql-function
Previous Message David G. Johnston 2015-04-07 21:54:56 Re: Setting the Field Separator in PSQL