Re: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database
Дата
Msg-id 6BCB9D8A16AC4241919521715F4D8BCEA0F8FD@algol.sollentuna.se
обсуждение исходный текст
Ответ на How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database  (Daniel Tourde <ted@foi.se>)
Ответы Re: How to import a CSV file (originally from Excel)  (Craig White <craigwhite@azapple.com>)
Re: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database  (Richard Broersma Jr <rabroersma@yahoo.com>)
Список pgsql-general
> Hello,
>
> I am trying to import an Excel file in my database (8.0.7). I
> think I am supposed to create an CSV file out of my Excel
> file and somehow, feed the database with it. My pronblem is
> that I don't really know how to do it... :( Can anyone give
> me a hint about how to do that?
> One last "detail", the Excel files contains roughly 45.000
> lines and 15 columns. So, I need a fast and efficient method.

Hi!

Is your problem with how to generate the CSV file from Excel, or with
how to import it into PostgreSQL?

For generation in Excel, you can just use File->Save, and select CSV as
the format. You can use either CSV or tab delimited, really.

Then to get it into postgresql, use the \copy command in psql (I'm
assuming your client is on windows, since you're using Excel. \copy will
run the process from the client, and will load it into your sever
regardless of platform). You can specify which delimiter to use there,
etc. From the example below, I'd guess you want something along the line
of:

\copy "Flight Traffic" from yourfile.csv delimiter as ',' csv quote as
'"'

(might need some adaption, of course)


Loading 45,000 lines is trivial for copy, it shouldn't take noticable
time at all.


If you need to load things regularly, you can use the excel ODBC driver
and write a small script to transfer it over to get rid of the manual
steps.

//Magnus

В списке pgsql-general по дате отправления:

Предыдущее
От: Ragnar
Дата:
Сообщение: Re: how to prevent generating same clipids
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: how to prevent generating same clipids