Re: Conversion of columns during CSV Import

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Conversion of columns during CSV Import
Date: 2012-07-01 07:33:28
Message-ID: jsoug8$ta6$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2012-06-29, Patrick Schneider <patrick(dot)schneider(at)debeka(dot)de> wrote:
> Hello,
>
> is there any possibility to convert special columns during an CSV import
> via COPY?
> For example:
>
> HELLO;WORLD;9999;011001
>
> 9999 should be converted to a character field

do you mean like '9999' (easy) or like '香' or like '✏' (harder)

> 011001 to the date 10th January 2001

I don't think there's any setting you can use to get postgres to
automatically translate 011001 to 10th January 2001 during a csv import

'20010110' would be doable

> For the moment the only idea we have is, to import the CSV into a TEMP
> table and
> perform the conversion by a select from the temp to the target table.

that's probably the best way.

--
⚂⚃ 100% natural

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2012-07-01 07:50:01 Re: Complex database infrastructure - how to?
Previous Message Edson Richter 2012-07-01 01:46:20 Re: Complex database infrastructure - how to?