Re: [despammed] CSV Import? - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: [despammed] CSV Import?
Date
Msg-id 20050715075213.GA23924@webserv.wug-glas.de
Whole thread Raw
In response to CSV Import?  (Lucius Seneca <peter.weinzierl@gmail.com>)
Responses Re: [despammed] CSV Import?
List 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@kaufbach:~$ cat csv.sql
1,3,5
4,2,8
kretschmer@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    ===

pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: Using Batch Files to Create DB Structure
Next
From: Bruno Wolff III
Date:
Subject: Re: Backups