RE: sql loader question

  • From: Stephen.Lee@xxxxxxxx
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Tue, 16 Mar 2004 21:12:29 -0600

> 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@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: