SSIS remove unwanted double quotes

SSIS has trouble processing embedded quadruple quotes.  Although my issue was with quadruple quotes, this script task could be used to remove any double quotes as well.

Example:
1,2,”These double quotes are “”inside”” other double quotes”, 4

The way to remove unwanted double quote or other characters was to use a script task.

Just run this Script Task before processing the file.

/* Script by GlutenFree SQL, Daniel Gras, 7/13/2013 */

public void Main()
{
// TODO: Add your code here
string filepath = (string)Dts.Variables["SourceTextFile"].Value;
var fileContents = System.IO.File.ReadAllText(filepath);
fileContents = fileContents.Replace("\"\"", "");

System.IO.File.WriteAllText(filepath, fileContents);

}

Here is where I got most of my information:
http://stackoverflow.com/questions/4339817/c-sharp-replace-string-within-file

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s