Skip site navigation (1) Skip section navigation (2)

Re: Command line option

From: John Purser <jmpurser(at)gmail(dot)com>
To: David <davidr(at)talamh(dot)org(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Command line option
Date: 2006-05-08 23:57:46
Message-ID: 20060508165746.3aa808b2.jmpurser@gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Tue, 9 May 2006 00:28:45 +0100
David <davidr(at)talamh(dot)org(dot)uk> wrote:

> Hi
> 
> How do I write my psql command line if I want the output to be tab  
> separated?
> 
> If I use psql interactively, I would go
> 
> #psql name_of_db
> 
> name_of_db =# \a
> name_of_db =# \f '\t'
> name_of_db =# \o outputfile.txt
> name_of_db =# \i queryfile.sql
> 
> This produces nice tab separated output that I can open in Excel and  
> that is recognised as such.
> 
> I understand that my command line should look like this:
> 
> psql -A -F something_to_produce_a_tab -f queryfile.sql -o  
> outputfile.txt name_of_db
> 
> But obviously I am struggling to get the string for  
> something_to_produce_a_tab right. I tried '\t' of course and many  
> variants of it, but I always ending up inserting the string
> literally (more or less).
> 
> Can somebody please help? I am on FreeBSD, using the bash shell and  
> PostgreSQL 8.1.2.
> 
> Thanks
> 
> DR
> 
> ---------------------------(end of
> broadcast)--------------------------- TIP 9: In versions below 8.0,
> the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match

David,

Try using  \pset fieldsep ’\t’ instead of the -F switch.

John Purser

-- 
... A solemn, unsmiling, sanctimonious old iceberg who looked like he
was waiting for a vacancy in the Trinity.
		-- Mark Twain

In response to

pgsql-novice by date

Next:From: Hari PatelDate: 2006-05-09 00:43:08
Subject: Setting sequence ids after importing data
Previous:From: DavidDate: 2006-05-08 23:28:45
Subject: Command line option

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group