Link to home
Start Free TrialLog in
Avatar of wdbates
wdbatesFlag for United States of America

asked on

Editing a file using C# or VB

Dear Microsoft Visual C# 2008 and Microsoft Visual Basic 2008Experts;

I need to edit a .CSV file using the Script Task within SSIS 2008.  The file will be comma delimited (,) or carrot delimited (^), text qualifier is a quote (“), header row delimiter is a line feed (LF) and column names in the first data row.  Searching though the file there is a common pattern of strings that needs replacing; examples inside the square brackets would be [“”)] replaced with [)], [“”.] replaced with [.], [ “,””] replaced with [“,”] and [\r\n] replaced with a blank space.

I have seen examples of .vbs scripts using replacement like;
 if !foo!==ex3 set foo=ex5
or
 If InStr(strLine,""")")> 0 Then
    	strLine = Replace(strLine,""")",")")

I need something to go within the Script Task in SSIS 2008.
Avatar of John_Vidmar
John_Vidmar
Flag of Canada image

I would assume strLine contains characters that need replacing and I would nest the replace-function:
strLine = Replace(Replace(Replace(Replace(strLine, "old1", "new1"), "old2", "new2"), "old3", "new3"), "old4", "new4")

Open in new window

ha ha, ;-)     caret not carrot
Avatar of wdbates

ASKER

Andy; you are correct!  And John, I need this in C# 2008 or VB 2008 and within SSIS script.
SOLUTION
Avatar of Mihai Stancescu
Mihai Stancescu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wdbates

ASKER

Thanks guys.  Sorry for the delay.