Re: Importing a CSV file to a table on Postgres

From: Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Importing a CSV file to a table on Postgres
Date: 2007-05-04 12:43:29
Message-ID: 1178282609.4760.11.camel@fukawi2.homelinux.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> 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;'"

You can do the same from pgAdmin, you just need to upload the file to
the server first, then do something like:
COPY table1 FROM '/tmp/file1.txt';

Remember to write the path as the SERVER will see it, not as the client
sees it!

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Mario Peshev 2007-05-04 13:45:42 Export SELECT statement as SQL queries in file
Previous Message A. Kretschmer 2007-05-04 12:24:36 Re: Importing a CSV file to a table on Postgres