Re: Importing a CSV file to a table on Postgres

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Importing a CSV file to a table on Postgres
Date: 2007-05-04 12:24:36
Message-ID: 20070504122436.GB21884@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

am Fri, dem 04.05.2007, um 12:48:24 +0100 mailte Oliveiros Cristina folgendes:
> Hello, list.
>
> I have a CSV file with two values/row and I would like to import it into a
> table who has two columns as well.
>
> Is there an easy and expedited way to do this with Postgres administration tool
> (PgAdmin)? I can do a program that parses the file and INSERTs the values on
> table, but I suspect that there is an easy way and that it is not worth the
> effort.

I'm not familiar with PGAdmin, but with console you can use a way like
this to insert the contents of a CSV-file into a database table on a
remote host:

cat <file.csv> | ssh <host> "psql -U <user> <database> -c 'copy <table> from stdin;'"

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Phillip Smith 2007-05-04 12:43:29 Re: Importing a CSV file to a table on Postgres
Previous Message Oliveiros Cristina 2007-05-04 11:48:24 Importing a CSV file to a table on Postgres