![](/img/trans.png)
[英]How to remove words in a flat file from a column string of words using SSIS
[英]How to remove empty rows using SSIS tools from a flat file source?
我正在尝试从SSIS中的平面文件中删除所有空行。 我尝试使用条件拆分解决此问题,但是该解决方案并不是我正在处理的任务的最佳选择。 我想知道是否有任何C#代码将删除可在脚本组件中使用的所有空行? 我是SSIS和c#的新手,因此将不胜感激。
这是一些C#可以帮助您。 您对空行的含义不是很清楚:
这将使用脚本组件,并使您可以处理非空行:
using System.IO; //This gets you to File (Way up top with the rest of the usings)
public static void Main()
{
string path = @"c:\[where ever you file is located].txt";
// Check path.
if (File.Exists(path))
{
string[] lines = File.ReadAllLines(path);
foreach(string line in lines)
{
if(!string.IsNullOrEmpty(line)) //Not null or empty
{
//[DO STUFF -- use split if you want to go to data flow]
}
}
}
}
如果您的平面文件源是Excel,请尝试以下链接中概述的方法。
https://devjef.wordpress.com/2014/02/05/ssis-remove-empty-rows-from-excel-import/
您提到条件拆分不是最好的方法,但是没有说明原因。 由于您是SSIS的新手,因此上述内容可能有助于验证您是否正确应用了它。
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.