Re: import CSV file to a table

From: Vick Khera <vivek(at)khera(dot)org>
To: Günce Kaya <guncekaya14(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: import CSV file to a table
Date: 2017-03-08 13:02:57
Message-ID: CALd+dcfmwycYbggHJAyrA3a0RLeVRmntywivGAXU8pfK1oPBUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Since you're using bash, I will assume you are not averse to using a
slightly complicated pipeline. First, install this:
https://github.com/wireservice/csvkit

Then use that to cut out the columns, you want and pipe the result into
psql with an appropriate \copy command.

On Wed, Mar 8, 2017 at 4:13 AM, Günce Kaya <guncekaya14(at)gmail(dot)com> wrote:

> Hi all,
>
> I want to import content of CSV file to a table via bash script without
> creating temporary table and I also want to skip some columns in CSV file
> (for instance, CSV file has 12 column and main table has only 2 column, If
> possible I would use only 2 column in CSV file) Is there any way to do it?
>
> Regards,
>
> --
> Gunce Kaya
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John McKown 2017-03-08 13:55:36 Re: import CSV file to a table
Previous Message Yogesh Sharma 2017-03-08 10:42:50 Re: Request to confirm which command is use for exclusive operation