Re: LOAD
Posted in 2000
Topics: Server Administration
From: Norma Garcia Montoya <ngarcia@iie.org.mx>
>
>Dear recipient:
Dear Poster:
>I execute a next command:
>
>load from "/usr2/informix/serme/energias/energias.csv" DELIMITER ","
> insert into energias;>
>The file energias.csv is resulted of export a table in db2:
>"TUL01",20,40
>"MAM01",10,30
>........
>
>My table energias have a next structure:
>
>nombre char(6);
>valor1 integer;
>valor2 integer;
>
>When I to execute a LOAD and to make query languaje select * from
>energias with dbaccess, the field nombre to load "TUL01 , "MAM01. Take
>a " ( double quotes) like character.
>I need to load this field without double quotes.
>e.g
> TUL01
> MAM01
>
>Can you help me please?
Pipe your file through sed, awk or tr to get rid of the "'s first.
Something like
cat /usr2/informix/serme/energias/energias.csv | tr -d \\" > /tmp/load
(You need the \\ to escape the " from the shell)
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
Obnoxio The Clown wrote:
>
> From: Norma Garcia Montoya <ngarcia@iie.org.mx>
> >
> >Dear recipient:
>
> Dear Poster:
>
> >I execute a next command:
> >
> >load from "/usr2/informix/serme/energias/energias.csv" DELIMITER ","
> > insert into energias;> >
> >The file energias.csv is resulted of export a table in db2:
> >"TUL01",20,40
> >"MAM01",10,30
> >........
> >
> >My table energias have a next structure:
> >
> >nombre char(6);
> >valor1 integer;
> >valor2 integer;
> >
> >When I to execute a LOAD and to make query languaje select * from
> >energias with dbaccess, the field nombre to load "TUL01 , "MAM01. Take
> >a " ( double quotes) like character.
> >I need to load this field without double quotes.
> >e.g
> > TUL01
> > MAM01
> >
> >Can you help me please?
>
> Pipe your file through sed, awk or tr to get rid of the "'s first.
>
> Something like
>
> cat /usr2/informix/serme/energias/energias.csv | tr -d \\" > /tmp/load
>
> (You need the \\ to escape the " from the shell)
Or you enclose it in single quotes...
Another alternative is the ubiquitous SQLCMD available from the IIUG
archives. It has a load/unload mode that works with CSV data (more or
less; there's always a chance that there are bugs in it -- and handling
embedded quotes in CSV is always interesting).
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"