Pentaho Kettle Group by with type concatenate 产生重复项
Pentaho Kettle Group by with type concatenate produces duplicates
我有以下 Excel 文件:
我的最终结果应该如下所示(第一个条目的输出文件示例):
<?xml version="1.0" encoding="utf-8"?>
<asset>
<asset_feature key="ItemID" value="12000"/>
<asset_feature key="Name" value="Name of the first item"/>
<asset_feature key="Price" value="1020.0"/>
</asset>
为了在初始步骤中实现它,我使用 Row Normaliser
步骤,然后是 Group by
类型 Concatenate strings separated by ,
。我期待这个:
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
并使用 XML Add - creating multi level XML files
示例中的技术进行 >, <
替换,如:var xmlOutput=xmlOrderListNew.replace(">, <","><");
,但我得到以下结果(3 行重复):
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
所以,要修复它,我必须添加额外的转换步骤才能获得 Unique rows
。变形图:
问题是:如何修复 Group by
步骤,以便在没有额外 Unique rows
步骤的情况下不重复,因为 XML Add - creating multi level XML files
不会'没有这样的问题吗?
可选问题1:有没有什么简单的拼接方法可以避免后面的replace(">, <","><")
步?
选答题2:如何制作漂亮的XML(带缩进)格式?
示例 Excel 和转换是 here
感谢您的帮助。
问题 0(避免分组重复):Un-check Include all row check box
!
问题 1(避免连接“,”):使用 Concatenate string separated by
(不带逗号)并且不要将任何内容作为 value
.
问题 2(小字 xml/html):您可以将任何函数放在 javascript 步骤中。特别是你可以复制一个 xml 漂亮的打印机,例如 formatXML.js
Un-asked 问题:使用 Memory Group by
而不是 Group by
步骤,除非你有非常大的数据。
我有以下 Excel 文件:
我的最终结果应该如下所示(第一个条目的输出文件示例):
<?xml version="1.0" encoding="utf-8"?>
<asset>
<asset_feature key="ItemID" value="12000"/>
<asset_feature key="Name" value="Name of the first item"/>
<asset_feature key="Price" value="1020.0"/>
</asset>
为了在初始步骤中实现它,我使用 Row Normaliser
步骤,然后是 Group by
类型 Concatenate strings separated by ,
。我期待这个:
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
并使用 XML Add - creating multi level XML files
示例中的技术进行 >, <
替换,如:var xmlOutput=xmlOrderListNew.replace(">, <","><");
,但我得到以下结果(3 行重复):
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
<asset_feature key="ItemID" value="12000"/>, <asset_feature key="Name" value="Name of the first item"/>, <asset_feature key="Price" value="1020.0"/>
所以,要修复它,我必须添加额外的转换步骤才能获得 Unique rows
。变形图:
问题是:如何修复 Group by
步骤,以便在没有额外 Unique rows
步骤的情况下不重复,因为 XML Add - creating multi level XML files
不会'没有这样的问题吗?
可选问题1:有没有什么简单的拼接方法可以避免后面的replace(">, <","><")
步?
选答题2:如何制作漂亮的XML(带缩进)格式?
示例 Excel 和转换是 here
感谢您的帮助。
问题 0(避免分组重复):Un-check Include all row check box
!
问题 1(避免连接“,”):使用 Concatenate string separated by
(不带逗号)并且不要将任何内容作为 value
.
问题 2(小字 xml/html):您可以将任何函数放在 javascript 步骤中。特别是你可以复制一个 xml 漂亮的打印机,例如 formatXML.js
Un-asked 问题:使用 Memory Group by
而不是 Group by
步骤,除非你有非常大的数据。