pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Medi Montaseri <montaseri@gmail.com>
To: Chris Hoover <revoohc@gmail.com>
Cc: pgsql-admin@postgresql.org Admin <pgsql-admin@postgresql.org>
Subject: Re: How to import CSV file?
Date: Tue, 28 Aug 2007 10:03:57 -0700
Message-ID: <8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com> (raw)
In-Reply-To: <1d219a6f0708280838q1312632fg7cbd971cec7cf5ee@mail.gmail.com>
References: <1d219a6f0708280838q1312632fg7cbd971cec7cf5ee@mail.gmail.com>

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@gmail.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
>

view thread (5+ messages)  latest in thread

Message-ID: <8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com>
Permalink:  ../8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com/
Also on:    postgresql.org/message-id/8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: montaseri@gmail.com, revoohc@gmail.com
  Subject: Re: How to import CSV file?
  In-Reply-To: <8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox