Re: Ragged CSV import

From: daveg <daveg(at)sonic(dot)net>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Ragged CSV import
Date: 2009-09-13 02:14:24
Message-ID: 20090913021424.GD25379@sonic.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 11, 2009 at 10:27:06AM +0200, Dimitri Fontaine wrote:
> Maybe instead of opening FROM for COPY, having it accepted in WITH would
> be better, the same way (from the user point of view) that DML returning
> are worked on.
...
> WITH csv AS (
> COPY t FROM stdin CSV
> )
> INSERT INTO foo(x, y, z)
> SELECT t[3], t[2], mytimestamptz([5], [6], [7])
> FROM csv;
>
> Now the text[] has a strange feeling, without it it'd be:
>
> WITH csv AS (
> COPY t(a, b, c, d, e, f, g)
> FROM stdin
> CSV IGNORING EXTRA COLUMNS -- random nice syntax
> MISSING COLUMNS DEFAULTS NULL -- that needs some reality check
> )
> INSERT INTO foo(x, y, z)
> SELECT c, b, mytimestamptz(e, f, g)
> FROM csv;
>
> The function mytimestamptz(date text, time text, timezone text) will
> accept input that PostgreSQL input types would have errored out on... so
> you can process in one go strange formats from other products.

+1

-dg

--
David Gould daveg(at)sonic(dot)net 510 536 1443 510 282 0869
If simplicity worked, the world would be overrun with insects.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-09-13 02:47:10 CommitFest 2009-09 Starting Soon - still need reviewers!
Previous Message Tom Lane 2009-09-13 01:43:21 Re: Re: [COMMITTERS] Can not create more than 32766 databases in ufs file system.