OpenRefine:创建列的移位副本 [英] OpenRefine: create a shifted copy of a column

查看:152
本文介绍了OpenRefine:创建列的移位副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道OpenRefine在创建新列时是否允许您从其他行访问数据.我怀疑不是这样的(这将是一个理智的设计原则),但是围绕它可能会有一些改动.

I wonder if OpenRefine lets you access data from other rows, when creating a new column. I suspect it does not (and it would be a sane design principle) but there could be a hack around that.

以下是一个示例:将一列移动一行.

Here is an example of what one could want to do: shifting a column by one row.

我有下表:

╔═════╦════════╗
║ row ║ Model  ║
╠═════╬════════╣
║   1 ║ Quest  ║
║   2 ║ DF     ║
║   3 ║ Waw    ║
║   4 ║ Strada ║
╚═════╩════════╝

我想获得以下结果:

╔═════╦════════╦══════════╗
║ row ║ Model  ║ Previous ║
╠═════╬════════╬══════════╣
║   1 ║ Quest  ║          ║
║   2 ║ DF     ║ Quest    ║
║   3 ║ Waw    ║ DF       ║
║   4 ║ Strada ║ Waw      ║
╚═════╩════════╩══════════╝

查看 https://github.com/OpenRefine/OpenRefine/wiki/Variables似乎没有任何变量可以让您访问当前行或记录之外的信息,所以我想知道这种操作是否可行.

Looking at https://github.com/OpenRefine/OpenRefine/wiki/Variables it seems that there isn't any variable that would let you access information outside the current row or record, so I wonder if this sort of operation is possible.

推荐答案

不幸的是,Open Refine中没有"column"变量.可能的解决方法是将所有数据集转换为一条记录,然后再应用一些Python/Jython.

Unfortunately, there is no "column" variable in Open Refine. A possible workaround would be to turn all the dataset into a single record, then apply a bit of Python/Jython.

示例:

data = row['record']['cells']['Model']['value']
for i, el in enumerate(data):
    if value == el and i !=0:
        return data[i - 1]

截屏:

我不知道是否可以在GREL中找到解决方案.

I don't know if a solution in GREL is possible.

这篇关于OpenRefine:创建列的移位副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆