Обсуждение: CSV Import?

Поиск
Список
Период
Сортировка

CSV Import?

От
Lucius Seneca
Дата:
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.

Thanks for any response

Lucius

PS: If there is something to read about csv-import into pg-sql I'd be
glad to get a url or a hint. Thanks

Re: [despammed] CSV Import?

От
Andreas Kretschmer
Дата:
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    ===

Re: [despammed] CSV Import?

От
Lucius Seneca
Дата:

Sorry for the late response.

Thank you for your answer.