Thread: Copy Command Error

Copy Command Error

From
"Richard Sydney-Smith"
Date:
I am outputting the following rows from a SYBASE database on W2000
 
3 '2' 'IBISFinancials' 'A.C.N. 072 378 815'
8 'RK' 'Personal Accounts' 
 
Using the command:
 
select cast(seq as integer) , id , cmpy, tr_n from fcont; output to d:\fcont.dat format 'ascii' delimited by '\x09'
 
This outputs the fields tab delimited and with strings encased in inverted commas
 
I then use the followin POSTRESQL command:
 
copy fcont (seq,id,cmpy,tr_n) from 'd:\\fcont.dat'
 
The problem is that each string is imported with the inverted commas.
 
eg field ID = ''RK'' instead of 'RK'
 
Can someone please help?
 
thanks
 
Richard
 
 

Re: Copy Command Error

From
Richard Huxton
Date:
On Monday 15 September 2003 09:57, Richard Sydney-Smith wrote:
> I am outputting the following rows from a SYBASE database on W2000

> The problem is that each string is imported with the inverted commas.
>
> eg field ID = ''RK'' instead of 'RK'
>
> Can someone please help?

A short bit of perl. Something like (untested)

perl -pi -e 's/\t"/\t/g' fcont.dat
perl -pi -e 's/"\t/\t/g' fcont.dat

That should pre-process the file. I'm sure someone else on the list will show 
how to do it in sed.

Hmm - just noticed you are on Windows. Not sure what cygwin ships with, or 
whether you have perl installed.
--  Richard Huxton Archonet Ltd