简体   繁体   English

Pentaho中表头的值

[英]Value to table header in Pentaho

Hi I'm quite new in Pentaho Spoon and I have a problem: I have a table like this: 嗨,我是Pentaho Spoon的新手,我有一个问题:我有一张这样的桌子:

model |  type | color| q 
--1---| --1-- | blue | 1 
--1---| --2-- | blue | 2 
--1---| --1-- | red  | 1
--1---| --2-- | red  | 3
--2---| --1-- | blue | 4
--2---| --2-- | blue | 5 

And I would like to create a single table (to export in csv or excel) for each model grouped by type with the value of the group as header and as value the q value: 我想为每个按类型分组的模型创建一个表(以csv或excel导出),其中group的值为header,值为q值:

table-1.csv 表1.csv

type | blue | red
--1--| -1-- | -1- 
--2--| -2-- | -3- 

table-2.csv 表2.csv

type |  blue 
--1--| -4- 
--2--| -5- 

I tried with row denormalizer but nothing. 我尝试使用行反规范器,但没有尝试。 Any suggestion? 有什么建议吗?

Typically it's helpful to see what you have done in order to offer help, but I know how counterintuitive the "help" on this step is. 通常,看看你做了什么以提供帮助是有帮助的,但我知道这一步骤的“帮助”是多么违反直觉。

Make sure you sort the rows on Model and Type before sending them to the denormalizer step. 确保在将模型和类型的行发送到非规范化器步骤之前对其进行排序。 Then give this a try: 然后尝试一下:

在此输入图像描述

As for splitting the output into files, there are a few ways to handle that. 至于将输出拆分为文件,有几种方法可以处理。 Take a look at the Switch/Case step using the Model field. 使用Model字段查看Switch / Case步骤。

Also, if you haven't found them already, take a look at the sample files that come with the PDI download. 此外,如果您还没有找到它们,请查看PDI下载附带的示例文件。 They should be in ...pdi-ce-6.1.0.1-196\\data-integration\\samples. 它们应该在...... pdi-ce-6.1.0.1-196 \\ data-integration \\ samples中。 They can be more helpful than the online documentation sometimes. 它们有时比在线文档更有用。

Row denormalizer can't be used here if number of colors is unknown, also, you can't define text output fields dynamically. 如果颜色数量未知,则此处不能使用行反规范器,也不能动态定义文本输出字段。

There are few ways that I can see without using java and js steps. 没有使用java和js步骤,我可以看到很少的方法。 One of them is based on the following idea: we can prepare rows with two columns: 其中一个基于以下想法:我们可以准备两列的行:

Row              Model
type|blue|red    1
1|1|1            1
2|2|3            1
type|blue        2
1|4              2
2|5              2

Then we can prepare filename for each row using Model field and then easily output all rows using text output where file name is taken from filename field. 然后我们可以使用Model字段为每一行准备文件名,然后使用文本输出轻松输出所有行,其中文件名取自filename字段。 In this case all records will be exported into two files without additional efforts. 在这种情况下,所有记录将导出到两个文件中而无需额外的努力。

Here you can find sample transformation: copy-paste me into new transformation 在这里你可以找到样本转换: 将我复制粘贴到新的转换中

Please note that it's a sample solution that works only with csv. 请注意,它是一个仅适用于csv的示例解决方案。 Also it works only if you have the same number of colors for each type inside model. 此外,只有当模型中的每种类型具有相同数量的颜色时,它才有效。 It's just a hint how to use spoon, it's not a complete solution. 这只是一个如何使用勺子的提示,它不是一个完整的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM