使用openrefine比较两个列表的差异

时间:2019-07-12 12:54:09

标签: openrefine

给出以下数据:

https://docs.google.com/spreadsheets/d/1GCbhf8w3cwJYi1gNWUTw4eW0qhGvTGBjpzlkwtCHbH8/edit#gid=0 如何报告两列之间的差异?

我们需要在第二列中了解哪些值已添加,哪些值已删除。这是对Google表格执行相同操作的方法(由于我的列表很大,我仍然遇到性能问题...)

https://www.prolificoaktree.com/google-sheets-compare-two-lists-for-matches-or-differences/

1 个答案:

答案 0 :(得分:0)

TL; DR

1°在数据集中添加一个第一个空列,然后在该列的第一个单元格中写入任何内容,like this

2°将数据集导入OpenRefine。确保只有一条记录。

enter image description here

3°通过选中“ Python / Jython”框来创建新列(“编辑列->基于此列添加列”)并使用此脚本(修改列名称以匹配实际数据集的名称)

original = row.record.cells["Column 2"].value
modified = row.record.cells["Column 3"].value

if value not in list(set(original) & set(modified)):
    return "new element"

enter image description here

4°如果您的数据确实很大,请考虑使用giving more memory to OpenRefine


要详细了解为什么在数据集开头添加此新列,请参见herehere

相关问题