如何在 OpenRefine 中使用一个键连接两个数据集,而第二个 table 具有多个值?

How can I join two datasets using a key in OpenRefine, with the secondary table having more than one value?

我有一个这样的数据集 X:

Code | Name
------------
123  | AAA
456  | BBB

另一个 Y 是这样的:

Code | Level
------------
123  | A
123  | B
456  | B
456  | C

我想使用 OpenRefine 加入他们这样的事情:

Code | Name | Level A | Level B | Level C
------------------------------------------
123  | AAA  |  value  |  value  |   -
456  | BBB  |    -    |  value  | value

当我尝试使用来自“X.Code”的 cell.cross() 添加列时,它仅从“X.Code' 在'Y'.

cell.cross("Y", "Code")[0].cells["Rede"].value[0]

如何使用 GREL 获得所需的输出?

您需要按 key/value 列化您的项目 Y,以便按级别设置一列,如下例所示。使用 Transpose -> Columnize by key/value

Code | Level A | Level B | Level C
------------------------------------------
123  | value  |  value  |   -
456  |   -    |  value  | value

然后您可以对每一列使用 cell.cross 函数。例如:cell.cross("Y", "Code")[0].cells["Level A"].value[0]将数据导入Project X