Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: sql loader question

RE: sql loader question

From: <Stephen.Lee_at_DTAG.Com>
Date: Tue, 16 Mar 2004 21:12:29 -0600
Message-ID: <D6339830FC73944E889CC3CEADDB205B0790928E@bu-dtagpo1.tracs.com>

> If I recall correctly, put two of them together like "".

After I wrote this, it occurred to me that you might not have any control over the format of the data. If that is the case, then you might be able to bring sed to bear (and if you are REALLY good, Uma Thurman to bare) to fix the data.

If EVERY case of a number followed by a quote was one that needed to be changed, then the following should work.

sed 's/[0-9]"/&"/g' datafile > new_datafile

If there are some cases where you have a number followed by a quote that should not be changed (for example, a telephone number field), then if the occurrence of the 6" is always in a particular field, maybe something like the following where we assume the 6" is in the third field and there are four fields total.

nawk '
BEGIN {FS=":";OFS=":";x=0}

{x = match($3,/[0-9]"/)}
{$3 = "\""substr($3,2,x)substr($3,x+1)}
{print $1,$2,$3,$4}

' datafile > new_datafile

(Maybe not the most elegant. It seems the sub() function should come in handy here, but I couldn't make it work, and my Sed and Awk book is at the office.)

Or the following with sed:

sed 's/\([^:]*:[^:]*[^0-9]*\)\([0-9][0-9]*"\)\(.*\)/\1\2"\3/' datafile > new_datafile



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Tue Mar 16 2004 - 21:17:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US