Re: Postgresql Copy

From: Jason Earl <jdearl(at)yahoo(dot)com>
To: Andrew Gould <andrewgould(at)yahoo(dot)com>, "samsom, debra" <dsamsom(at)bristol(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql Copy
Date: 2001-10-31 23:31:56
Message-ID: 20011031233156.30490.qmail@web10005.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yeah, that's what I do as well. With just a little
bit of work you can make this sort of thing really
easy to do. The trick is to create a script (I
generally use Python as well, but Perl is good too)
that reads from stdin and writes to stdout and that
looks like what pg_dump spits out (which is very
trivial). That way you can use it like this:

cat my_file | custom_filter | psql -e my_database

making it easy to automate.

Jason

--- Andrew Gould <andrewgould(at)yahoo(dot)com> wrote:
> I think that is correct. If I'm wrong, I'm sure
> I'll
> be corrected.
>
> I import fixed width data using one of two methods:
>
> 1. I import the data into MS Access, which can deal
> with fixed width data; and then I move the data to
> PostgreSQL via ODBC connection.
>
> 2. There's a huge fixed width file that I receive
> every quarter. Since the structure is the same, I
> wrote a python script that copies the data to a new
> file, inserting tab delimiters and stripping out the
> extra spaces as it goes. The resulting file is
> often
> one third the size of the original. I then use copy
> to import the tab delimited data into PostgreSQL.
>
> If you'd like me to send the python script, let me
> know. Basically, you'll have to adjust the file to
> fit your data table's definition. (Or send me the
> definition of one table and I'll adjust it this
> once.)
> In any case, the original file is left unchanged
> should anything go wrong.
>
> Best of luck,
>
> Andrew Gould
>
>
>
> --- "samsom, debra" <dsamsom(at)bristol(dot)ca> wrote:
> > Is there away to copy fixed length text files into
> > an Postgresql table.
> > After reading the doc's it looks Postgresql
> expects
> > some sort of delimiter.
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
> (send "unregister YourEmailAddressHere" to
majordomo(at)postgresql(dot)org)

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roderick A. Anderson 2001-10-31 23:37:47 Re: Postgresql Copy
Previous Message Lamar Owen 2001-10-31 22:35:53 Re: fresh install of postgres 7.1 doesn't start postmaster with the "-i" flag