Re: How to remove quotes from COPY TO result? - Mailing list pgsql-novice

From Michael Wood
Subject Re: How to remove quotes from COPY TO result?
Date
Msg-id AANLkTi=s91hqGohomXdgyiiRUTA=24+SzZSaHv3bybvt@mail.gmail.com
Whole thread Raw
In response to Re: How to remove quotes from COPY TO result?  (Bruce Momjian <bruce@momjian.us>)
Responses Re: How to remove quotes from COPY TO result?  (Joseph Conway <mail@joeconway.com>)
List pgsql-novice
On 10 August 2010 00:53, Bruce Momjian <bruce@momjian.us> wrote:
> Joe Conway wrote:
> -- Start of PGP signed section.
>> On 07/17/2010 09:45 PM, Michael Rowan wrote:
>> > PostgreSQL 8.4.1
>> >
>> > I have a table "abbreviation" created as follows:
>> >
>> > id serial NOT NULL, full_name character varying(16), short_name
>> > character varying(16),
>> >
>> > I import some data from a tab delimited text file like so:
>> >
>> > 1   "STREET"                "ST"
>> > 2   "ROAD"                  "RD"
>> >
>> > using COPY abbreviation FROM <<myfile>>
>> >
>> > The data is imported but I want the character columns to be stripped
>> > of the enclosing double-quotes and they are not.  What do I have to
>> > do?
>>
>> See:
>>   http://www.postgresql.org/docs/8.4/interactive/sql-copy.html
>>
>> COPY abbreviation FROM 'filename' WITH DELIMITER '\t' CSV;
>> select * from abbreviation;
>>  id | full_name | short_name
>> ----+-----------+------------
>>   1 | STREET    | ST
>>   2 | ROAD      | RD
>> (2 rows)
>
> How were the double-quotes removed?

Doesn't the "WITH ... CSV" handle that automatically?

The documentation implies to me that quotes would be stripped,
although it talks more about writing CSV files than reading them.  I
haven't tried it, though.

--
Michael Wood <esiotrot@gmail.com>

pgsql-novice by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: How to remove quotes from COPY TO result?
Next
From: Joseph Conway
Date:
Subject: Re: How to remove quotes from COPY TO result?