Re: Copying entire tsv record (from file) into a single field

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: Allan Kamau <kamauallan(at)gmail(dot)com>
Cc: Postgres General Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Copying entire tsv record (from file) into a single field
Date: 2010-12-07 11:14:13
Message-ID: 4CFE1705.5070508@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/12/2010 11:07, Allan Kamau wrote:
> I would like to use copy to populate a single row in table with data
> from a tsv file for further transformations.
> I seem not find a way to stop copy from seeing that the tsv file does
> indeed contain fields.
> This my current query
>
> COPY raw_data
> (
> raw_record
> )
> FROM
> '/tmp/some.tsv'
> ;

You can specify the character which COPY sees as the field delimiter to
be something other than a tab - maybe a comma, if there are no commas in
your input:

copy raw_data(raw_record)
from '/tmp/some.tsv'
with delimiter ',';

Would that do the job?

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Veyron 2010-12-07 11:20:16 Re: Implement online database using Postgresql
Previous Message Raimon Fernandez 2010-12-07 11:11:27 SELECT is immediate but the UPDATE takes forever