Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: sql loader question
> 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}
(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
-- 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
![]() |
![]() |