dbTalk Databases Forums  

CSV Pre-reader

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss CSV Pre-reader in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
NH
 
Posts: n/a

Default CSV Pre-reader - 07-28-2005 , 08:41 AM






I have a .csv output from a database which does not use text qualifier.

any commas or backslashes in the data are 'escaped' I.e.

Field1 Field2 Field3
123 a,b\cd grey

would come out like:

123,a\,b\\cd,grey

I want to DTS this .csv file into SQL Server, but i need to find and replace
the "\," and "\\" 's in the file with something before I do the import.

I would like to add this to the DTS package. Can anyone suggest how to do
it? Can and ActiveX Script do a find and replace on the file before it moves
on to the import step?

Thanks

Nick

Reply With Quote
  #2  
Old   
Rick Gittins
 
Posts: n/a

Default Re: CSV Pre-reader - 08-01-2005 , 04:56 PM






There are 2 different aproaches you can do for this:
1) Modify the export to replace the "\" and "\\" with spaces.
2) Created a new ActiveX script that will user the file system object to
open the file and read through the it line by line and write the data to a
new file that you will import via a data transformation. Before you write
the data out to the text file you would use the replace function to replace
all the "\" and "\\" with spaces.

Let me know if you have any more questions with this.

Rick

"NH" <NH (AT) discussions (DOT) microsoft.com> wrote

Quote:
I have a .csv output from a database which does not use text qualifier.

any commas or backslashes in the data are 'escaped' I.e.

Field1 Field2 Field3
123 a,b\cd grey

would come out like:

123,a\,b\\cd,grey

I want to DTS this .csv file into SQL Server, but i need to find and
replace
the "\," and "\\" 's in the file with something before I do the import.

I would like to add this to the DTS package. Can anyone suggest how to do
it? Can and ActiveX Script do a find and replace on the file before it
moves
on to the import step?

Thanks

Nick



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.