如何转换 table 格式或其结构 Google Refine

How convert a table format or it structure with Google Refine

我有一个 table,格式如下:

ID  Estation    Y   M   D   H   N   Nh     h   Cl
1   78357     2017  5   1   1   0   0   -9001   0
2   78357     2017  5   1   2   0   0   -9001   0
3   78357     2017  5   1   3   1   1    750    5

我想将此table中的数据转换为以下格式:

ID  Estation    Y   M   D   H   Var Value
1   78357     2017  5   1   1   N    0
2   78357     2017  5   1   2   N    0
3   78357     2017  5   1   3   N    1
4   78357     2017  5   1   1   Nh   0
5   78357     2017  5   1   2   Nh   0
6   78357     2017  5   1   3   Nh   1
7   78357     2017  5   1   1   h   -9001
8   78357     2017  5   1   2   h   -9001
9   78357     2017  5   1   3   h    750
10  78357     2017  5   1   1   Cl   0
11  78357     2017  5   1   2   Cl   0
12  78357     2017  5   1   3   Cl   5

由于注册量大,我必须从一种格式转换为另一种格式,因此我想使用 Google Refine 来完成。有人知道怎么做吗?

您可以在 Google Refine(现在称为 OpenRefine)中使用转置选项执行此操作。

在 'N' 列中单击下拉菜单并选择 "Transpose -> Transpose cells across columns into rows"

在显示的屏幕中,选择 "N" 作为 "From Column",选择“(最后一列)”作为 "To Column"

选择转置到两个新列中。调用键列 "Var" 和值列 "Value"

选中 "Fill down in other columns"

单击转置

这应该会在多行的单列中为您提供各种变量和值

按照您在示例中给出的顺序进行排序可能具有挑战性。如果您按相反的字母顺序对 Var col 进行排序,它虽然不完全正确,但很接近 - 不确定这对您有多重要。

请记住,在 OpenRefine 中,您必须选择永久重新排序行才能提交新的排序顺序。

您可能需要转换 ID 列以使用唯一 ID 重新编号。您可以使用 GREL rowIndex+1 一旦您的排序顺序正确