I know the issue of dynamically exposing attributes in a feature reader from the Generic port comes up often, but I thought I would ask anyway. I have two issues with the FeatureReader regarding scripted parameters.
Firstly, I have a text file which contains a list of feature classes to read. As feature classes are added to the database, the name will be added to the text file. I have a Python Scripted Parameter which is called "FeatureTypes" with the following code:
f = open(r"D:\Scripts\DEV\List of Feature Classes.txt", 'r')
featureTypes = ''
for line in f.read().split('\n'):
featureTypes += (line + " ")
f.close
return featureTypes
This returns a nice list of all feature classes to read. In my FeatureReader, I set the Feature Types to Read paramter, to this $(FeatureTypes) parameter. However, when the database tries to read it, it's reading the literal string "$(FeatureTypes)" instead of the list. I got around this by using a ParameterFetcher and storing the list of feature classes into an attribute called _FeatureTypes. That's a suitable workaround to what seems like a bug.
Next, because each of these feature classes have a lot of different attributes, I have another text file which contains all possible attributes across all feature classes. The idea is, that when a new feature class is added, and it gets added to the text file of feature classes, any fields that hadn't been previously on the list will get added to the text file of attributes.
I have another python scripted parameter called $(AssetAttributes) which will, in theory, do the same thing for attributes.
f = open(r"D:\Scripts\DEV\List of Asset Attributes.txt", 'r')
AssetAttributes = ''
for line in f.read().split('\n'):
AssetAttributes += (line + " ")
f.close()
return AssetAttributes
I set the generic port to expose these attributes by selecting the $(AssetAttributes) parameter,
However, the issue is that it's treating the parameter as a literal string. So, instead of exposing the attributes, I get this:
Note, I cannot hard-code the attributes because it is possible that people will add new feature classes with new attributes. I want this to run without any manual intervention. Also, I don't mind if features have NULL values for attributes that aren't on the original feature.
I'm using FME 2020.0.2.1 Build 20238 Win64.
Is this a bug? Or is what I'm trying to do simply not possible?