dbTalk Databases Forums  

import text - consecutive delimiters

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


Discuss import text - consecutive delimiters in the microsoft.public.sqlserver.dts forum.



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

Default import text - consecutive delimiters - 01-14-2006 , 10:34 PM






Hello,

I am trying to import a comma delimited text file with double quotes as the
text qualifier. The DTS is scheduled daily. I don't control the source
file contents. The latest file included a field with another set of double
quotes in the field. When the dts runs I get an error, Invalid Delimited
data: text qualifier must be followed by a column delimiter

I have tried to use the replace function in an activex script but I can't
get it to work.

Here is the text causing the problem:

"18717","BRENZAN","ROGER "CRAIG"","HDO"

Here is the Activex Script I am trying to use to replace it:

Function Main()
dim s1

Const ForReading = 1
Const ForWriting = 2

s1 = ("ROGER "CRAIG"")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\importdata\unitrax\reptabl e.txt",
ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, s1,"CRAIG")

Set objFile = objFSO.OpenTextFile("c:\importdata\unitrax\reptabl e.txt",
ForWriting)
objFile.WriteLine strNewText
objFile.Close


this script should find the problem and replace it but I can't get it to
work, it says it expected ')' in the search string.

Any suggestion would be appreciated.

Graham




Reply With Quote
  #2  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: import text - consecutive delimiters - 01-17-2006 , 08:00 AM






Graham,

Replace appropriate lines with the following:

s1 = ("""ROGER ""CRAIG"""")
strNewText = Replace(strText, s1,"""CRAIG""")

This would be an immediate solution on you part. Next time it will brake in
different place. Probably the best solution here is in informing the file
source party so they are aware of the issue.

Ilya

"Graham Martin" <gmar595 (AT) rogers (DOT) com> wrote

Quote:
Hello,

I am trying to import a comma delimited text file with double quotes as
the
text qualifier. The DTS is scheduled daily. I don't control the source
file contents. The latest file included a field with another set of
double
quotes in the field. When the dts runs I get an error, Invalid Delimited
data: text qualifier must be followed by a column delimiter

I have tried to use the replace function in an activex script but I can't
get it to work.

Here is the text causing the problem:

"18717","BRENZAN","ROGER "CRAIG"","HDO"

Here is the Activex Script I am trying to use to replace it:

Function Main()
dim s1

Const ForReading = 1
Const ForWriting = 2

s1 = ("ROGER "CRAIG"")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\importdata\unitrax\reptabl e.txt",
ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, s1,"CRAIG")

Set objFile = objFSO.OpenTextFile("c:\importdata\unitrax\reptabl e.txt",
ForWriting)
objFile.WriteLine strNewText
objFile.Close


this script should find the problem and replace it but I can't get it to
work, it says it expected ')' in the search string.

Any suggestion would be appreciated.

Graham






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.