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

From: Daniel Tourde <ted(at)foi(dot)se>
To: pgsql-general(at)postgresql(dot)org
Subject: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database
Date: 2006-04-11 08:24:30
Message-ID: 200604111024.30145.ted@foi.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Here is my database:

--
-- PostgreSQL database dump
--

SET client_encoding = 'UNICODE';
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = public, pg_catalog;

--
-- Data for Name: Flight Traffic; Type: TABLE DATA; Schema: public; Owner: ted
--

COPY "Flight Traffic" ("AR", "ICAOAIRP", "MOTORTYP", "VIKT", "ICAOTYP",
"FROMTO", "ANTAL", "CLASS", "SUBCLASS", "BULLERKLASS", "MILJOKLASS",
"ANTAL_PAX", "ARRDEP", "INTDOM", "KUNDNAMN") FROM stdin;
2004 ESDF - 0 RALL ESME 1 P F 3
0 0 A D FORSBERG
\.

--
-- PostgreSQL database dump complete
--

And here is the .CSV i try to import:

2004,"ESDF","-",0,"RALL","ESME",1,"P","F",3,0,0,"A","D","FORSBERG, N MARTIN"

Daniel
--
**********************************************************************
Daniel TOURDE E-mail : daniel(dot)tourde(at)foi(dot)se
Tel : +46 (0)8-55 50 32 12
Fax : +46 (0)8-55 50 30 68
Cellular : +46 (0)70-849 93 40
FOI, Swedish Defence Research Agency; Systemteknik
Department of Aviation Environmental Research
SE-164 90 Stockholm, Sweden
**********************************************************************

Browse pgsql-general by date

  From Date Subject
Next Message MG 2006-04-11 09:08:57 Performance UPDATE/INSERT
Previous Message Richard Huxton 2006-04-11 08:01:49 Re: installing and using autodoc