Re: Importing undelimited files (Flat Files or Fixed-Length records)

From: "Gregory Williamson" <Gregory(dot)Williamson(at)digitalglobe(dot)com>
To: "Bill Thoen" <bthoen(at)gisnet(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing undelimited files (Flat Files or Fixed-Length records)
Date: 2008-06-19 23:58:04
Message-ID: 8B319E5A30FF4A48BE7EEAAF609DB233021F2E66@COMAIL01.digitalglobe.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Thoen asked:

>
> I've got to load some large fixed-legnth ASCII records into PG and I was
> wondering how this is done. The Copy command looks like it works only
> with delimited files, and I would hate to have to convert these files to
> INSERT-type SQL to run them through psql.. Is there a way one can
> specify a table structure with raw field widths and then just pass it a
> flat file?

One possibility might be to create a table with one column of type text, load the data into that table with copy, and then, after creating the real table structure, populate it with the data by using substr and casts to get it into shape.

HTH,

Greg Williamson
Senior DBA
DigitalGlobe

Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information and must be protected in accordance with those provisions. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

(My corporate masters made me say this.)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message blackwater dev 2008-06-20 00:34:33 Re: finding firstname + lastname groups
Previous Message Ralph Smith 2008-06-19 23:53:10 Re: A plpgsql unidentifiable problem.