【问题标题】:OpenRefine overwrites unique ID from database if rows are the same如果行相同,OpenRefine 会覆盖数据库中的唯一 ID
【发布时间】:2019-05-31 16:18:39
【问题描述】:

我从我的 postgresql 数据库上传了一个 openrefine 数据集。在我的表中,我有一个主键“id”。

然后,我在打开的精炼中清理我导入的表,做以下两件事:

1) 聚类并合并包含地址位(“address_line_1”、“address_line_2”、“address_country”等)的几列,以便我可以将"london" "lodon" "londres" 等条目合并到london 等...

2) 基于address_line_1 添加一列address_full,然后将其他列与以下GREL 连接:

if(isBlank(cells["address_line_1_normalised"].value), " ", 
cells["address_line_1_normalised"].value)  
+ ' ' 
+ if(isBlank(cells["address_line_2_normalised"].value), " ", 
cells["address_line_2_normalised"].value)
+ ' '
+ if(isBlank(cells["address_town_normalised"].value), " ", 
cells["address_town_normalised"].value)
+ ' '
+ if(isBlank(cells["address_county_normalised"].value), " ", 
cells["address_county_normalised"].value)
+ ' '
+ if (isBlank(cells["address_postcode"].value), " ", 
cells["address_postcode"].value)
+ ' '
+ if(isBlank(cells["address_country_normalised"].value), " ", 
cells["address_country_normalised"].value)

3) 对full_address 进行聚类和合并,使地址标准化。

在这里我会很高兴,并想在 postgres 中再次上传,但是在提取的那一刻,我意识到 某些 id 编号是相同的,这应该是不可能的,经过仔细查询我认为有些行已被其他行压碎。

--详情--

1) 我确定我在 pg 表中有唯一的 ID。 2)从pg获取数据到openrefine的查询是: select * from schema_name.table_name; 3)我在open优化中编辑后的csv输出将以这样的id系列开头。

1
2
3
...
-> from row 265 it would go like this 
265 (same record 265)
265 (same record 265)
266 (same record 266)
266 (same record 266)
266 (same record 266)
267 (same record 267)
267 (same record 267)
267 (same record 267)
...
-> up until row number 2456 (whose id is 1245) and from here starts again the unique increment of the id column:
1245
1246
....
-> up until 4000 something - where it has a jump of several thousands. 
6234 

我想 openrefine 只是覆盖了所有丢失的记录,并将重复行的所有 id 与列表中第一个的 id 相结合。

有谁知道 openrefine 的工作原理知道如何反转这个?

【问题讨论】:

  • 您能否显示您的表的架构以及您用于在 OpenRefine 中检索数据的查询?

标签: export uniqueidentifier openrefine grel


【解决方案1】:

听起来很简单 - 错误在于从 postgresql 将数据导入 OR。我使用 csv 重新导入数据,然后在 UID 列中为重复项设置一个方面 - 发现当从 pg 创建项目时,一半的记录被其他记录覆盖,而使用 csv 时,没有记录覆盖。

结论:使用到数据库的连接在OR中创建项目是错误的,不要使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-20
    • 2022-12-12
    • 2016-08-03
    • 2017-03-26
    • 2014-03-16
    • 1970-01-01
    • 2013-06-28
    • 1970-01-01
    相关资源
    最近更新 更多