Re: How to import CSV file?

From: "Chris Hoover" <revoohc(at)gmail(dot)com>
To: "Medi Montaseri" <montaseri(at)gmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org Admin" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to import CSV file?
Date: 2007-08-28 18:02:56
Message-ID: 1d219a6f0708281102g7d42c0e9od3b02787fba173fe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Why go through all of this when COPY can handle this for you? All I need to
know is the syntax to tell copy that the strings are quoted by a single
quote.

Thanks anyway.

On 8/28/07, Medi Montaseri <montaseri(at)gmail(dot)com> wrote:
>
> This might not be the quickest way, but it is a skill you'll be happy to
> have gained.
>
> Perl has a class (or module) called CSV.pm, you feed it a file, and it
> does the rest (parsing it) and gives an array for each row. You can then
> alter them (however you wish) and write them to a file suitable for pg copy,
> or just use DBI to insert it into the PG. Which is basically an ETL
> (Extract, Transform, Load). I know insert is slower, but the point was to
> show a general way that will always for.
>
> Cheers
> Medi Montaseri
>
> On 8/28/07, Chris Hoover <revoohc(at)gmail(dot)com> wrote:
> >
> > I need some help importing a csv file. I have been given a csv file
> > full of data that is delimited by a comma, and the strings are delimited by
> > a single quote. How do you write the copy statement to use a single quote
> > delimiter? I have tried several things, but so far, no joy.
> >
> > Thanks for any help,
> >
> > Chris
> >
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2007-08-28 18:06:56 Re: How to monitor resources on Linux.
Previous Message Medi Montaseri 2007-08-28 17:03:57 Re: How to import CSV file?