Re: Is it possible to import .txt files in PostgreySQL

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Murali Mohan Kasetty <kasetty(at)india(dot)hp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is it possible to import .txt files in PostgreySQL
Date: 2002-10-01 19:02:45
Message-ID: 20021001190245.14720.qmail@web20804.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Weaver, Walt 2002-10-01 19:08:29 Re: Is it possible to import .txt files in PostgreySQL
Previous Message Johnson, Shaunn 2002-10-01 18:46:54 Re: execute transaction / insert rows