span8
斯潘4
Duplicate attribute values are those where multiple features share the same value for the same attribute.在许多情况下,这是自然的和预期的;例如,对于许多记录,地址数据库的省(县/州)字段很可能是相同的。
然而,在某些情况下,重复的值是无效的和意外的;例如,应为唯一ID的字段包含与另一个功能(1、2、3、4、4、5、6)相同的值。
重复的ID值,in particular,使用唯一索引键加载到数据库时可能导致完整性错误。
有时,只要与另一个字段具有特定关系,重复值就有效;例如:
第1栏 | 第2栏 |
1 | 一 |
1 | 乙 |
1 | c |
二 | 一 |
二 | 乙 |
二 | c |
二 | c |
或:……第一列有重复项,但是,第1列和第2列的组合是独特的(因此对于2a,2B,2c,2c,决赛2c是无效的,因为它是与以前的组合匹配)
第1栏 | 第2栏 |
1 | 一 |
1 | 一 |
1 | 一 |
二 | 乙 |
二 | 乙 |
二 | 乙 |
二 | c |
…如果列1有重复项,但它有效,因为它与列2相匹配(因此对于2b,2B,2B,2c,这个2c值无效,因为它是不a match for a previous combination).
Duplicate attribute values can be identified with either the复式过滤器变压器或Matchertransformer.Matcher Transformer很好地查找一列重复的关系,并且由于另一列不同而无效(2b,2B,2B,2C示例)
The Matcher transformer is also better at extractingall重复记录,as the DuplicateFilter lets the first instance of a duplicate record pass.但同样的行为使得复制过滤器的内存效率更高,因此,如果可能的话,最好是这样。
It's fairly simple to identify and count duplicate values,但修复可能需要人工干预,取决于字段要包含的内容类型。
Locate Duplicate Attributes: Workspace as a Template
此示例的源数据集是一个Excel电子表格,其中包含温哥华市的营业执照信息。
数据集在FME数据检查器(表视图)中如下所示:
有多列,但特别是,我们对三个关键ID号感兴趣:
文档编号is a unique ID number throughout the entire dataset;即每个记录都应具有不同的值。
许可人数是可以重用的ID号,因此可能不唯一。Also,同一许可证编号可能有多个记录;例如,a single business that operates at multiple addresses will have a record in the dataset for each address (but with the same LicenseNumber).
LicenseRSNis a unique ID number per license;即颁发的每个许可证都应具有唯一的许可证持有人N。Of course,也可能有多个记录具有此值,因为它应该匹配多个licenseNumber功能的每个记录。
The scenario here is to check for duplicate values.We can say that RecordID must be fully unique.Also,while each LicenseRSN might have multiple records,it should only ever match to a single LicenseNumber.
按照以下步骤学习如何识别重复的属性值。
1。Start FME Workbench and begin with an empty canvas.
从菜单栏中选择“读卡器>添加读卡器”。
将数据格式设置为Microsoft Excel。选择附加文件作为源数据集。单击参数按钮查看参数并检查源数据预览。默认参数值应该可以使用,所以单击“确定”关闭此对话框,然后再次单击“确定”添加读卡器。
2.要检查的第一个问题是重复的recordid值。我们要用一个复制变压器来做这个。所以把一个复制变压器放在画布上,已连接到读卡器功能类型(表)。
在“参数”对话框中,选择“记录ID”作为“关键属性”参数:
三。将Inspector Transformer连接到复制端口并运行转换。One duplicate RecordID is found and output to the Data Inspector.记录ID号是4854。
只显示重复记录;即它是的副本的记录也不会被筛选。In many cases,this is enough to satisfy our needs.然而,if we want to be able to look at both records we'll have to open the full dataset:
“高级烟花集团”营业执照注销时,看起来“基拉尼咖啡厅”(下一个将要颁发的许可证)错误地给出了他们的记录ID号。
4.要进行的下一个检查是重复的licensersn值。重复值本身不是问题,除非重复值的licenseNumber值不同(即licensersn:licenseNumber应为1:1匹配)。For this,we'll use a Matcher transformer.
Place a Matcher transformer connected to the Unique output port on the DuplicateFilter:
检查匹配器参数并设置以下内容:
5。将inspector transformer连接到matcher:matched输出端口并运行转换。将有四个记录标识为匹配:
For the "Electronic Enterprises Corp." it looks like one of their LicenseNumbers contains a typo (120097 instead of 120079).很难确定另一个副本的原因。
Notice that this transformer has given us both instances of the duplicate record,not just one of them;however there is a performance cost associated with this benefit,所以这并不总是最好的解决方案。
6。我们可以做的最后一个检查是使用不同的许可证颁发者n进行重复的许可证编号。因为(如上所述)licenseNumber值可以重用,所以可能有很多这样的值。然而,这种复制只会在两个许可证同时处于活动状态时导致问题。
所以,firstly add a Tester transformer connected to the Matcher:NotMatched output port:
设置参数以测试状态为“已颁发”的许可证。
7。将第二个匹配转换器添加到工作区,这个连接到测试仪:通过端口。像以前一样设置,除此之外,licenseNumber是所选属性,和许可方的属性必须不同:
8。将inspector transformer连接到此matcher的匹配端口并运行工作区。There will be 10 features that exit through the Matched port:
即这些功能具有与同一个许可证号码不匹配的重复许可证号码。
Counting duplicate attribute values is simple enough,这只是一个决定重复值的每个实例是否算作一个问题的例子,或者它是否是所有匹配值的一个问题(例如,如果两个功能都具有许可证编号17-107142,does that count as one issue,or two?)
Additionally,有必要决定是单独计算所有不同类型的重复项,还是作为一个重复项。
9.要计算重复的特性,只需要在任何检查器转换器之前使用一个统计计算器。所以,在matcher:matched端口和inspector之间添加一个statisticscaleculator,并将其设置为分析任何属性。
在“计算属性”参数中,remove all of the values.在totalCountAttribute下输入duplicateCount:
10.重复的recordid功能被duplicatefilter过滤,结果只有1个功能被标记为重复(它是重复的记录不计算在内)。
Matcher结果将为每个匹配提供两个功能。如果你只想把它算作一个问题,the duplicate duplicates(!) need to be filtered out.This is simply done by switching the connection from Matcher:Matched to Matcher:SingleMatched:
Fixing duplicate attribute values is also simple,前提是您只希望删除一个匹配的记录。在那种情况下,空间筛选器已删除副本的单个实例。For the Matcher it only requires that the SingleMatched features are kept;the other matches will then be discarded.
Of course,it's sometimes necessary to ascertain which record should be filtered.Transformers to use in that scenario will vary depending on what rules govern the records to keep and the records to discard.有时需要保留两个记录,但为其中一个指定一个新值。In that scenario the Counter can provide new IDs and the StatisticsCalculator can find the current maximum value of an ID in order to determine which is the next available value.
It's very difficult to fix duplicates that are caused by simple typos (120097 instead of 120079) without manual intervention.
这里使用的数据来源于温哥华市提供的开放数据,不列颠哥伦比亚(数据.couver.ca).It contains information licensed under the Open Government License - Vancouver.
Great article thanks - how would you handle "calculated duplicates",如果多个值将一个项标记为重复项?例如:
资产ID | 友好名称 | Status | |
1 | ABC123 | 退休了 | 好/忽略 |
二 | ABC123 | Existing | Duplicate |
3 | ABC123 | New | Duplicate |
所以实际上,"Existing" and "New" mean the same thing in terms of a duplicate.
这是个有趣的问题。值得在论坛上问一下,看看其他用户是否有好主意。Personally my first thought is to separate out the acceptable records (say Status = Retired) using a Tester so that any remaining matches must be an incorrect feature.另一种方法是为特定的状态值设置标志。So use an AttributeValueMapper to set xxxx;如果状态=失效,则XXXX=0,如果状态=存在,则XXXX=1,如果状态=新,则XXXX=1。然后您可以在友好名称和XXXX上进行匹配。
© 2019 亚搏在线Safe Software Inc |Legal