I have this script task which must convert a number of Tab Delimited Files from utf8 -> unicode.
It runs rather slow. How can i improve the script code?
public void Main()
{
Dts.TaskResult = (int)ScriptResults.Success;
string path= (string)Dts.Variables["dataPath"].Value;
string name = (string)Dts.Variables["fileName"].Value;
string from = Path.Combine(path, name) + ".tsv";
string to = Path.ChangeExtension(from, "txt");
using (StreamReader reader = new StreamReader(from, Encoding.UTF8, false, 1000000))
using (StreamWriter writer = new StreamWriter(to,false, Encoding.Unicode, 1000000))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Length>0)
writer.WriteLine(line);
}
}
}
I have done whatever i can in order to improve the disk activity , everything is running on the same raid array disk which is the fastest i can get.
Any suggestions ofr the upper code to be faster in the SSIS pipeline?
Additional Info:
i tried to replace the while with this:
while (reader.Peek() >= 0)
{
writer.WriteLine(reader.ReadLine());
}
i dont know if it is beneficial i am testing it now.