Re: Ragged CSV import

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: 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-11 14:59:23
Message-ID: 4AAA65CB.9070307@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I wrote:
> I'd love to be able to do something like
>
> INSERT into foo (x,y,z) select t[3],[t2],[t57] from (COPY RETURNING
> t FROM stdin CSV);
>
>

Some IRC discussion suggested ways we could do better than that syntax.
I think my current preferred candidate is something like

COPY foo (a,b,c)
FROM stdin
CSV
AS t USING (t[3],t[2],[t57]);

I'm not sure how we'd could plug a filter into that. Maybe a WHERE
clause? My immediate need at least doesn't actually involve filtering
anything - we load every line in the CSV into a temp table and then
filter what we load into the main tables after applying the business rules.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-09-11 15:04:06 Re: COPY enhancements
Previous Message Emmanuel Cecchet 2009-09-11 14:53:33 Re: COPY enhancements