Question

How to iterate a list of attribute?

  • 21 September 2018
  • 5 replies
  • 43 views

Hi, I asked about comparing the attributes of two datasets which have same attribute table earlier, and @DanAtSafe helped me out. But now I have a lot datasets to compare and they don't have same attribute table, which means every time I have to create a new comparing workbench, that's a lot work and I may miss some attributes or set the wrong parameters.

So I'm thinking about creating a custom transformer to iterate coming feature's attributes. I've been looking into help documents about Looping, but it seems that's not possible to get the count of the incoming attribues, not to mention iterate them. ListElementCounter will only come back with the count of the list, not the attributes in the list.

Figure1 below is the whole workbench I created based on Dan's method, Figure2 below is the part of workbench with summary annotation, and Figure3 is all the input attributes of a pair of datasets, I want to compare all attributes in the differ{} list.

I'm not sure FuzzyStringComparer would work or not, and there're too many versions of them.

Please help me out, I don't want to go the old fashion way, thank you guys.

 

@takashi @Mark2AtSafe @MarkAtSafe @DanAtSafe @jdh


5 replies

Userlevel 2
Badge +17

I think you can use a schema feature read from the source dataset effectively. This is an example:

detect-different-attributes-between-two-datasets.fmwt (FME 2018.1.0.2)

If you need more generic and/or more efficient way, consider implementing a similar logic with a PythonCaller, as @DanAtSafe has suggested in the previous thread already.

I think you can use a schema feature read from the source dataset effectively. This is an example:

detect-different-attributes-between-two-datasets.fmwt (FME 2018.1.0.2)

If you need more generic and/or more efficient way, consider implementing a similar logic with a PythonCaller, as @DanAtSafe has suggested in the previous thread already.

 

Thank you for helping me on the weekend! I studied the attached template yesterday, it is what I wanted, but my data is not that "clean". The 2 datasets don't have same rows of data and I have to do a lot data filter work before compare them. After connected data output from other transformer to FeatureReader, I tried to use spatial filter parameter but I can't get the data I wanted, maybe it's about the tolerance or EsriReprojector.

 

Is there any other way to expose feature schema?

 

And for Python script, I'm not very familiar with it, I can only use it in Arcgis field calculator to do some easy calculations like if…else…. It would be very nice of you if you can show me a sample script which I can modify myself.

 

Further more, happy Tsukimi to you, may you see a full moon!
Userlevel 2
Badge +17

I think you can use a schema feature read from the source dataset effectively. This is an example:

detect-different-attributes-between-two-datasets.fmwt (FME 2018.1.0.2)

If you need more generic and/or more efficient way, consider implementing a similar logic with a PythonCaller, as @DanAtSafe has suggested in the previous thread already.

There isn't a perfect way to configure schema automatically unless a schema source (source dataset, external dataset, lookup table, etc.) is provided. As a workaround, you can create a custom transformer which allows the user to select attributes to be compared through a published parameter. See the attached example to learn more.

 

detect-changed-attributes.fmwt (FME 2018.1.0.2)

 

 

I think you can use a schema feature read from the source dataset effectively. This is an example:

detect-different-attributes-between-two-datasets.fmwt (FME 2018.1.0.2)

If you need more generic and/or more efficient way, consider implementing a similar logic with a PythonCaller, as @DanAtSafe has suggested in the previous thread already.

Thank you again. I found this SchemaSetter in FME hub, it seems to be able to expose attributes like FeatureReader, but I can't get it working. I keep getting this error:

 

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal.

 

I googled this message online but there's no specific answer to it. I'm thinking maybe it is caused by Python version, I'm using Python 2.7 installed together with Arcgis. Or it is caused by attribute values in the dataset, most of them are not English characters. Or it is caused by data type, all my data is stored in ESRI FileGeoDatabase. Any ideas why?

 

 

Userlevel 2
Badge +17

I think you can use a schema feature read from the source dataset effectively. This is an example:

detect-different-attributes-between-two-datasets.fmwt (FME 2018.1.0.2)

If you need more generic and/or more efficient way, consider implementing a similar logic with a PythonCaller, as @DanAtSafe has suggested in the previous thread already.

In the current implementation of the SchemaSetter, unfortunately, the UnicodeDecodeError could occur if you use Python 2.7 and an attribute name contains non-ascii characters. You could avoid the error if you could use Python 3.x.

 

 

Reply