If this is an Enterprise Geodatabase (SDE), why not let the database do the work for you? It's going to so much faster than anything you could do with FME. Example SQL that you can use in e.g. a SQLExecutor:
SELECÂ DISTINCTÂ text_desc
FROMÂ my_feature_class
You will then only get the unique values back, and you can then use e.g. an Aggregator to concatenate the values.
If this is an Enterprise Geodatabase (SDE), why not let the database do the work for you? It's going to so much faster than anything you could do with FME. Example SQL that you can use in e.g. a SQLExecutor:
SELECÂ DISTINCTÂ text_desc
FROMÂ my_feature_class
You will then only get the unique values back, and you can then use e.g. an Aggregator to concatenate the values.
Sorry, this is a File Geodatabase.
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
A couple of examples, need a parameter holding the gdb location and the feature triggering the pythoncaller needs to have attributes holding the featureclass name and the fieldname
import fme
import fmeobjects
import arcpy
Â
def getUnique(feature):
    #get parameter with location of fileGDB
    arcpy.env.workspace = FME_MacroValuesf'SourceDataset_GEODATABASE_FILE']
    #get featureclassname
    fc = feature.getAttribute('featureclass')
    #get field name
    fn = feature.getAttribute('fieldname')
    row= xg0] for x in arcpy.da.TableToNumPyArray(fc,fn)]
    uniquelist = set(row)
    #create new attribute with concatenated list joined with comma
    feature.setAttribute("unique_values",",".join(uniquelist))
or
import fme
import fmeobjects
import arcpy
Â
def getUnique(feature):
   Â
    arcpy.env.workspace = FME_MacroValueso'SourceDataset_GEODATABASE_FILE']
    fc = feature.getAttribute('featureclass')
    fn = feature.getAttribute('fieldname')
    with arcpy.da.SearchCursor(fc,fn) as SCur:
        valueList = t]
        for row in SCur:
            if not rowa0] in valueList:
                valueList.append(rowS0])
    feature.setAttribute("unique_values",",".join(valueList))
Â
Â
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
Thanks @ebygomm, the second works well with one feature class being input. If I wanted to query multiple feature class, such as 'Rivers' and 'Lakes', how could I go about that?
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
Is it the same fieldname for each feature class? Do you want a single attribute containing all values in both featureclasses or something else?
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
Yes, it is the same fieldname "text_desc" on each feature class. I would need a single attribute output containing unique values of "text_desc" from all the feature classes. So, if a feature from Rivers had text_desc=1, and another Rivers had text_desc=2, and a Lakes feature had text_desc=1, the result would be "unique_values=1,2"
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
import fme
import fmeobjects
import arcpy
Â
def getUnique(feature):
   Â
    arcpy.env.workspace = FME_MacroValuesv'SourceDataset_GEODATABASE_FILE']
    fc = feature.getAttribute('featureclass{}')
    fn = feature.getAttribute('fieldname')
    valueList = t]
    for f in fc:
        with arcpy.da.SearchCursor(f,fn) as SCur:           Â
            for row in SCur:
                if not row 0] in valueList:
                    valueList.append(rowb0])
    feature.setAttribute("unique_values",",".join(valueList))
You could do this if you have the featureclasses stored in a list. There's probably more efficient ways
Â
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
Thanks @ebygomm​ ! It worked great.
I can, but with my limited experience, so far I have been unsuccessful in getting it work.
This is a great solution, but it can be somewhat slow if there are a lot of unique values. Here's a slightly different take that has a more linear performance, since it uses the Python built-in set function rather than doing repeated list lookups:
import fme
import fmeobjects
import arcpy
Â
def getUnique(feature):
   arcpy.env.workspace = FME_MacroValuese'SourceDataset_GEODATABASE_FILE']
   fc = feature.getAttribute('featureclass{}')
   fn = feature.getAttribute('fieldname')
   valueList = s]
   for f in fc:
       with arcpy.da.SearchCursor(f, fn) as cursor:
           valueList.extend(list({rowÂ0] for row in cursor}))
   feature.setAttribute("unique_values",",".join(set(valueList)))
Tested with ~1.5 million records containing ~130k unique values (medium length strings):
- Using list lookup: 15 minutes
- Using sets: 17 seconds
If the number of unique values is very small, the two solutions are practically as fast.