我正在尝试导入一个以制表符分隔且文本限定符为双引号的文本文件。下面是我的指南:http://www.ideaexcursion.com/2008/11/12/handling-embedded-text-qualifiers/
我想要下面的文本
"655295" "Keisuke" "" "Ueda" "1-2-2, Central Park East F201" "Utase, Mihama-Ku"转换为
"655295","Keisuke","","Ueda","1-2-2, Central Park East F201","Utase, Mihama-Ku"我尝试过派生列转换,但没有帮助。我尝试了脚本组件,但也不起作用。有人能帮帮我吗。
提前谢谢你!!
发布于 2015-02-26 11:07:06
我在脚本组件中使用了以下代码:
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
/*
* Add your code here
*/
String inputString = Row.line.ToString();
int count = Row.line.Split('"').Length - 1;
int counter = 1;
while (counter < count)
{
if (counter % 2 == 0)
{
int StartIndex = GetNthIndex(inputString.ToString(), Convert.ToChar("\""), counter);
int EndIndex = GetNthIndex(inputString.ToString(), Convert.ToChar("\""), counter + 1);
inputString = inputString.ToString().Substring(0, StartIndex + 1) + "," +
inputString.ToString().Substring(EndIndex);
}
else
{
}
counter = counter + 1;
}
Row.OutputLine = inputString;
}
int GetNthIndex(string s, char t, int n)
{
int count = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] == t)
{
count++;
if (count == n)
{
return i;
}
}
}
return -1;
}发布于 2015-02-26 17:34:44
获取一个变量并将字符串存储在变量中。
然后使用派生列使用字符串函数作为
REPLACE(@user:Variable1,"\" \"","\",\"")这将适用于您的问题...
发布于 2015-02-26 21:09:52
您可以通过以下步骤来实现此目标:
行分隔符= {CR}{LF} ii.Modifey column delimited = {CR}并刷新metadeta,这样您将只看到一列。请给它一个具体的名称,我现在将它称为"Col“。
您将在新的列中获得以下所需的输出-
"655295","Keisuke","","Ueda","1-2-2, Central Park East F201","Utase, Mihama-Ku"您可以将此输出放在不同的平面文件中,并使用不同的DFT或包将该文件导入到表中,或者您可以添加脚本组件将其拆分为不同的列,以便您可以使用相同的DFT将数据导入到表中。
https://stackoverflow.com/questions/28732149
复制相似问题