Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 8E7FD9F9A7D for ; Tue, 28 Aug 2007 14:04:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 37559-07-2 for ; Tue, 28 Aug 2007 14:04:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by postgresql.org (Postfix) with ESMTP id 2C9EE9F9FF9 for ; Tue, 28 Aug 2007 14:04:03 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id u77so1882013pyb for ; Tue, 28 Aug 2007 10:03:58 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=i50FPpG/h5mg+/uWE9RNh5sOeXtKOC56kCTvNT0IuGY1FsnTTBTfTrIIgnBQ/jTYiz+VWveEFBeHotqZ7xDqRoKIo41MiXAkAt8sl5eeID21tlYm9Pq8zRTZiJ/8FXRaMEAGMCO/2dYlgH1hfyzkJYWOIotJcHPViANkzkY/QuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=qrP0YlqNFkNeBQBMHCU2BF5QzcrM+l3/uvBipeCl/aCGpOwsHV92gwZhYpwpyZcpkZn+B8SjgkeCZ/uY/eSs0gVp4GqpbRu4qRSaK/1u3ns5Th+AzefBDoSyRsLTNi1qfE8xjDCyotUVymlcvbMdnO5H/hWOI8wBr1w5l0bpLLo= Received: by 10.64.153.4 with SMTP id a4mr13536451qbe.1188320637141; Tue, 28 Aug 2007 10:03:57 -0700 (PDT) Received: by 10.65.110.15 with HTTP; Tue, 28 Aug 2007 10:03:57 -0700 (PDT) Message-ID: <8078a1730708281003n30db4b2eu40f4865672ebab76@mail.gmail.com> Date: Tue, 28 Aug 2007 10:03:57 -0700 From: "Medi Montaseri" To: "Chris Hoover" Subject: Re: How to import CSV file? Cc: "pgsql-admin@postgresql.org Admin" In-Reply-To: <1d219a6f0708280838q1312632fg7cbd971cec7cf5ee@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3229_18088813.1188320637098" References: <1d219a6f0708280838q1312632fg7cbd971cec7cf5ee@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/351 X-Sequence-Number: 26682 ------=_Part_3229_18088813.1188320637098 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 > ------=_Part_3229_18088813.1188320637098 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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

------=_Part_3229_18088813.1188320637098--