Re: Importing undelimited files (Flat Files or Fixed-Length records) - Mailing list pgsql-general

From Gregory Williamson
Subject Re: Importing undelimited files (Flat Files or Fixed-Length records)
Date
Msg-id 8B319E5A30FF4A48BE7EEAAF609DB233021F2E66@COMAIL01.digitalglobe.com
Whole thread Raw
In response to Importing undelimited files (Flat Files or Fixed-Length records)  (Bill Thoen <bthoen@gisnet.com>)
List 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.)

pgsql-general by date:

Previous
From: Ralph Smith
Date:
Subject: Re: A plpgsql unidentifiable problem.
Next
From: Adrian Klaver
Date:
Subject: Re: Importing undelimited files (Flat Files or Fixed-Length records)