| From: | Andreas Kretschmer <akretschmer(at)despammed(dot)com> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: [despammed] CSV Import? | 
| Date: | 2005-07-15 07:52:13 | 
| Message-ID: | 20050715075213.GA23924@webserv.wug-glas.de | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
am  10.07.2005, um 17:00:06 +0200 mailte Lucius Seneca folgendes:
> Hi,
> 
> does anybody know whether I could use any sign for CSV-Import into PGSQL or 
> does it have to
> be a comma? Problem is that I got a couple of datasets which have that 
> character included and I can't change them, also inverted commas are used, 
> thus CSV-Import.
You can use \copy from psql.
kretschmer(at)kaufbach:~$ cat csv.sql
1,3,5
4,2,8
kretschmer(at)kaufbach:~$ psql test
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
test=> delete from csv_import ;
DELETE 2
test=> \copy csv_import from 'csv.sql' delimiter ','
\.
test=> select * from csv_import;
 a | b | c
---+---+---
 1 | 3 | 5
 4 | 2 | 8
(2 rows)
Regards, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    === 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruno Wolff III | 2005-07-15 17:03:48 | Re: Backups | 
| Previous Message | John DeSoi | 2005-07-15 05:30:50 | Re: Using Batch Files to Create DB Structure |