From this thread. > Community: Merge and Flag
Assume there are these two tables.
FileA:
Name | Postcode | DOB |
---|---|---|
Bob | NG1 1AA | 01/01/1970 |
Sue | WP1 1AA | 01/01/1990 |
Name | Postcode | DOB |
---|---|---|
Bob | NG1 1AA | 01/01/1970 |
John | SW1 1AA | 01/01/1980 |
The question was how to merge the tables; the result table must not contain duplicated person's row, and must have additional columns which indicate existence in the original tables.
Required result table should be:
Required result table should be:
Name | Postcode | DOB | FileAFlag | FileBFlag |
---|---|---|---|---|
Bob | NG1 1AA | 01/01/1970 | Yes | Yes |
Sue | WP1 1AA | 01/01/1990 | Yes | No |
John | SW1 1AA | 01/01/1980 | No | Yes |
In the Community, an excellent solution using the FeatureMerger has been provided. If I created a workspace according to the solution, the first step for merging tables would be like this.
Immediately after the tables were merged, every "FileBFlag" of NotMerged features and every "FileAFlag" of Unreferenced features are <missing>, i.e. not exist. To satisfy the requirement, finally those <missing> attributes should have a specific value - "No".
The subject I think of here is how to assign "No" to <missing> attributes after merging.
One possible way is to use an AttributeCreator with conditional value setting. "Attribute Is Missing" operator can be used in the setting.
There is another way in FME 2014. That is to use a NullAttributeMapper in order to assign "No" to <missing> FileAFlag and FileBFlag.
Both of them work fine, I cannot say which way is better. But the NullAttributeMapper parameter setting looks simpler than conditional value settings in the AttributeCreator.
I would use the NullAttributeMapper if I encountered a similar requirement.
-----
It's also possible that adding "FileBFlag" (= "No") to NotMatched output and adding "FileAFlag" (= "No") to Unreferenced output in the FeatureMerger using the "Edit Attribute" tool.
If did so, both the AttributeCreator and the NullAttributeMapper would not be necessary no longer, but the process would become difficult to be visible. It's good or not ...
No comments:
Post a Comment