Question

compare field attributes (of same table)

  • 22 March 2016
  • 7 replies
  • 96 views

Badge

Hello,

I would like to compare two attributes of the same table: e.g. a table of features with the following attributes: UID, old name, new name.

I would like to know for which features the old name is the same as the new name and identify the features whose name has changed.

Afterwards I would like to create new tables for all (and only) these features whose name has changed, one with the UID and the old name and one with the UID and the new name.

Which transformers should I use ?

Thanks for you help!


7 replies

Userlevel 4

Hi

You can use the Tester to compare old name with new name and then act accordingly. This assumes that the same feature contains both the new and the old name.

If you need to compare names between different features based on the UID as key, you could either use the FeatureMerger or the Matcher.

David

Userlevel 2
Badge +12

Assuming your source is in a database I would use two SQLCreators:

First with SQL: Select UID, new_name from <table> where new_name != old_name.

Second with SQL: Select UID, old_name from <table> where new_name != old_name.

You can write the result to new tables.

Badge

Hi @kat

One more option:

  • with Tester new_name != old_name you can filter out all features you are not interested in;
  • the remaining features (all of them) can be written into two destination feature types (i.e. each feature will be written twice):
    • feature type #1 will have UID and old_name (but no new_name);
    • feature type #2 will have UID and new_name (but no old_name).
Badge

Perfect.Thank you. I already have another question: If I have a table of features with the following attributes: country, city, population. I have several cities per country. How can I create a new table and keep only the cities whose population is the biggest of a country? Thanks!

Userlevel 2
Badge +12

Hi @kat.

Here is a possible solution:

Read the table in FME.

Use Aggregator with group by Country. Choose to use a list (Cities).

Use a ListSorter (sort on population numeric descending).

Use the ListIndexer (index 0).

The output of the ListIndexer will be a list of countries and the city with the highest population per country.

Userlevel 2
Badge +17

Hi @kat, another approach for your additional question:

  1. Sorter: sort all the records by population descending.
  2. DuplicateFilter (DuplicateRemover in FME 2015 and earlier): filter out duplicate country records.

Hi

You can use the Tester to compare old name with new name and then act accordingly. This assumes that the same feature contains both the new and the old name.

If you need to compare names between different features based on the UID as key, you could either use the FeatureMerger or the Matcher.

David

by using Featuremerger i have merged 2 tables then how to compare attribute values of all fields

Reply