将多个列中的多值单元格拆分为多行(Open Refine)

时间:2015-09-28 20:49:45

标签: openrefine

我一直在Open Refine上清理一张桌子。我现在有这样的话:

var dataURL = canvas.toDataURL({
                format: 'png',
                multiplier: 20
            })

            var pdf = new jsPDF();
            pdf.addImage(dataURL, 'PNG', 0, 0);
            pdf.save("download.pdf");
        }

我需要在REF和Size中拆分那些多值单元格,以便得到:

REF                 Handle      Size        Price
2002, 2003          t-shirt1    M, L        23
3001, 3002, 3003    t-shirt2    S, M, L     24

是否可以在Open Refine中执行此操作? "拆分多值单元格......"命令只处理一列。 谢谢, 安娜丽塔

2 个答案:

答案 0 :(得分:3)

是的,有可能:

  • 使用“,”作为分隔符拆分第1列。
  • 将第2列移至第1位
  • 将您的项目显示为记录(不是行)
  • 使用“,”作为分隔符
  • 拆分第3列
  • 填写第4栏和第2栏
  • 重新排序列

这是我在GREL中的食谱:

[
  {
    "op": "core/row-removal",
    "description": "Remove rows",
    "engineConfig": {
      "facets": [
        {
          "invert": false,
          "expression": "row.starred",
          "selectError": false,
          "omitError": false,
          "selectBlank": false,
          "name": "Starred Rows",
          "omitBlank": false,
          "columnName": "",
          "type": "list",
          "selection": [
            {
              "v": {
                "v": true,
                "l": "true"
              }
            }
          ]
        }
      ],
      "mode": "row-based"
    }
  },
  {
    "op": "core/multivalued-cell-split",
    "description": "Split multi-valued cells in column Column 1",
    "columnName": "Column 1",
    "keyColumnName": "Column 1",
    "separator": ", ",
    "mode": "plain"
  },
  {
    "op": "core/column-move",
    "description": "Move column Column 2 to position 0",
    "columnName": "Column 2",
    "index": 0
  },
  {
    "op": "core/multivalued-cell-split",
    "description": "Split multi-valued cells in column Column 3",
    "columnName": "Column 3",
    "keyColumnName": "Column 2",
    "separator": ", ",
    "mode": "plain"
  },
  {
    "op": "core/fill-down",
    "description": "Fill down cells in column Column 4",
    "engineConfig": {
      "facets": [],
      "mode": "record-based"
    },
    "columnName": "Column 4"
  },
  {
    "op": "core/fill-down",
    "description": "Fill down cells in column Column 2",
    "engineConfig": {
      "facets": [],
      "mode": "record-based"
    },
    "columnName": "Column 2"
  },
  {
    "op": "core/column-reorder",
    "description": "Reorder columns",
    "columnNames": [
      "Column 1",
      "Column 2",
      "Column 3",
      "Column 4"
    ]
  }
]

埃尔韦

答案 1 :(得分:0)

刚刚找到了一个不错的免费 OpenRefine 插件,它提供了“未配对的枢轴”: VIB-Bits plugin

来自their documentation

3.2.1 未配对枢轴... 未配对数据透视是将按行组织的数据转换为该数据的表示 单独列中的数据。一个简单的例子是转换

<头>
类别 价值
1
2
b 3
c 2

进入

<头>
值a 值 b 值 c
1 3 2
2