Is it possible to import .txt files in PostgreySQL

Started by Murali Mohan Kasettyover 23 years ago4 messagesgeneral
Jump to latest
#1Murali Mohan Kasetty
kasetty@india.hp.com

Hi All,

Is it possible to import data from .txt files into PostgreySQL
7.1.3. If so , How do I do it?

Any help would be greatly appreciated.

Thanks in advance,
Murali

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Murali Mohan Kasetty (#1)
Re: Is it possible to import .txt files in PostgreySQL

On Tue, Oct 01, 2002 at 05:40:42PM +0530, Murali Mohan Kasetty wrote:

Hi All,

Is it possible to import data from .txt files into PostgreySQL
7.1.3. If so , How do I do it?

Any help would be greatly appreciated.

\copy in psql can copy delimited files. There is a similar facility using
the pq library.

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

There are 10 kinds of people in the world, those that can do binary
arithmetic and those that can't.

#3Jeff Eckermann
jeff_eckermann@yahoo.com
In reply to: Martijn van Oosterhout (#2)
Re: Is it possible to import .txt files in PostgreySQL
--- Martijn van Oosterhout <kleptog@svana.org> wrote:

On Tue, Oct 01, 2002 at 05:40:42PM +0530, Murali
Mohan Kasetty wrote:

Hi All,

Is it possible to import data from .txt files

into PostgreySQL

7.1.3. If so , How do I do it?

Any help would be greatly appreciated.

\copy in psql can copy delimited files. There is a
similar facility using
the pq library.

One small point: if your .txt file originated on a
Windows machine, the lines will be terminated by
carriage return/line feed pairs. Since unix-type
operating systems only recognize the line feed as a
line terminator, the carriage return would be included
in your data. This is almost certainly not what you
want. You would need to delete those carriage returns
before importing your data. Something like:
perl -pi -e 's/\r$//' <datafile>

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

#4Weaver, Walt
wweaver@rightnow.com
In reply to: Jeff Eckermann (#3)
Re: Is it possible to import .txt files in PostgreySQL

Or use dos2unix...

--Walt

-----Original Message-----
From: Jeff Eckermann [mailto:jeff_eckermann@yahoo.com]
Sent: Tuesday, October 01, 2002 1:03 PM
To: Martijn van Oosterhout; Murali Mohan Kasetty
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Is it possible to import .txt files in
PostgreySQL

--- Martijn van Oosterhout <kleptog@svana.org> wrote:

On Tue, Oct 01, 2002 at 05:40:42PM +0530, Murali
Mohan Kasetty wrote:

Hi All,

Is it possible to import data from .txt files

into PostgreySQL

7.1.3. If so , How do I do it?

Any help would be greatly appreciated.

\copy in psql can copy delimited files. There is a
similar facility using
the pq library.

One small point: if your .txt file originated on a
Windows machine, the lines will be terminated by
carriage return/line feed pairs. Since unix-type
operating systems only recognize the line feed as a
line terminator, the carriage return would be included
in your data. This is almost certainly not what you
want. You would need to delete those carriage returns
before importing your data. Something like:
perl -pi -e 's/\r$//' <datafile>

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)