Re: How to LOAD selected columns from a delimited file?
Posted in 1997
Check the dbload utility. It can do this easily.
Of course striping the unwanted collumns with a Unix tool isn't
exactly hard either, but dbload has other features as well.
Matt Reprogle <mcreprog@mail.delcoelect.com> wrote:
:I have searched the docs, but cannot find out how use the LOAD command
:to insert selected columns from a delimited file. Example:
:
:data.psv (input file)
:-----------
:ID|PRODUCT|VAL1|VAL2|VAL3
:24|XYZ|1.2|3.4|5.6
:
:columns in table "tests":
:-------------------------
:id
:product
:val1
:val3
:
:I want to do something like (%%bad syntax alert!%%):
:load from "data.psv" columns(ID,PRODUCT,VAL1,VAL3) insert into tests
:
:or
:
:load from "data.psv" insert into tests(id,product,val1,NULL,val3)
:or
:load from "data.psv" insert into tests(id,product,val1,,val3)
:
:The first one is bad syntax, and the last two fail when executed.
:Is something like this possible, or do I have to strip the unwanted
:columns from the input file first to make it match the table?
:
:TIA,
:
:--
:Matt Reprogle
:Delco Electronics - IC Integrated Manufacturing phone:(317)451-9651
:mcreprog@koicew00.delcoelect.com FAX: (317)451-8230
Nils.Myklebust@idg.no
NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway
My opinions are those of my company
The Informix FAQ is at http://www.iiug.org