0

在表数据中,我必须 [*,=,#,&,^,%]从表数据中删除这些。我不应该删除这些

[(,),/,.,@,',",:-,_,,\]将数据从数据移动mssqlmysql使用pentaho数据时的特殊字符

一体化

例子:-

Gujarat is the country’s largest castor oil seed producing state. The m*ajor 

month’s 
4

3 回答 3

0

为什么不在用于检索数据的查询中使用正则表达式?它将简化您的转型!

于 2015-01-30T14:22:03.707 回答
0

您可以在 Spoon中使用Regex Evaluationstep 或stepString operations在此处输入图像描述

尝试它们,如果您仍然有问题,请在下面评论。

于 2015-02-03T07:28:55.820 回答
0

您可以在 Pentaho 中使用“用户定义的 Java 类”并使用替换函数编写正则表达式。

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException{
Object[] r = getRow();
if (r == null) {
    setOutputDone();
    return false;
}

if (first)
{
    first = false;
}

r = createOutputRow(r, 1);


if(get(Fields.In, "data").getString(r) != null) 
{
    String output= get(Fields.In, "data").getString(r);

    output= output.replaceAll("[^a-zA-Z0-9\\s()/\\.@-_]+","");

    get(Fields.Out, "output").setValue(r, output);

}else {
    get(Fields.Out, "output").setValue(r, "");
}

putRow(data.outputRowMeta, r);

return true;
}

data是输入流数据,清理后的输出将在“输出”列中。我在这里分享了一个示例代码。

希望这能解决您的问题。:)


修改我之前的答案以包含完整的代码。话虽如此,我最近还创建了一个插件来处理特殊字符。你可以看看我的博客网站:

博客链接:https ://anotherreeshu.wordpress.com/2015/01/07/special-character-remover-clean-your-data-of-special-characters-pentaho-kettle-step-plugin/

虽然它只有1.0.0版本,但你可以试一试。它也可能对你有帮助:)

于 2015-01-05T16:52:48.980 回答