Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
改进文本文件转换的SSIS脚本任务_Ssis - Fatal编程技术网

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

改进文本文件转换的SSIS脚本任务,ssis,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; str

我有一个脚本任务,它必须从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());
        }

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

我的方法最后不起作用,所以我删除了答案,很抱歉UTF-8是unicode,为什么需要转换它?请参阅此链接:我通过文本文件从4个非unicode AS400获取数据。如果我不这样做,我就不能得到正确的字符。。。