改进文本文件转换的SSIS脚本任务

时间:2015-01-08 09:08:28

标签: ssis

我有这个脚本任务,必须从utf8转换许多制表符分隔文件 - >的unicode。

它运行得相当慢。我该如何改进脚本代码?

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);
        }
    }       

}

为了改善磁盘活动,我已尽其所能,所有内容都在同一个raid阵列磁盘上运行,这是我能够获得的最快速度。

上层代码的任何建议在SSIS管道中要更快?

其他信息:

我试图用这个代替while:

        while (reader.Peek() >= 0)
        {
            writer.WriteLine(reader.ReadLine());
        }

我不知道我现在正在测试它是否有益。

0 个答案:

没有答案
相关问题