Hey - I'm using a python caller to execute this script (shortened version of original script):
---------------------------------------------------------------------------------------------------------
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
self.Types = T]
self.features = .]
def input(self, feature):
if feature.getAttribute('_is_ftr_type'):
self.Types.append(feature.getAttribute('Feature_Type'))
else:
self.features.append(feature)
def close(self):
# Create and output a Schema Feature
schema = fmeobjects.FMEFeature()
schema.setAttribute('fme_schema_handling', 'schema_only') # indicates it's a schema feature
schema.setAttribute('fme_feature_type_name', 'MySchema') # schema definition name
schema.setAttribute('fme_geometry{0}', 'fme_area') # geometry type definition
schema.setAttribute('attribute{0}.name', 'Element-ID')
schema.setAttribute('attribute{0}.fme_data_type', 'fme_varchar(200)')
schema.setAttribute('attribute{1}.name', 'Name')
schema.setAttribute('attribute{1}.fme_data_type', 'fme_varchar(30)')
schema.setAttribute('attribute{2}.name', 'Area')
schema.setAttribute('attribute{2}.fme_data_type', 'fme_real64')
for i, type in enumerate(self.Types, 3):
schema.setAttribute('attribute{%d}.name' % i, type)
schema.setAttribute('attribute{%d}.fme_data_type' % i, 'fme_real64')
self.pyoutput(schema)
# Output Data Features
for feature in self.features:
self.pyoutput(feature)
---------------------------------------------------------------------------------------------------------
MySchema goes in dynamic schema definition in my excel writer and we've got three fixed columns (Element-ID,Name, Area) and the respective data that goes in there. After the third column (actually in the script it is column"3", because column counting starts at 0), name and data is read in dynamically (all this is coming from DGNs and the columns are equivalent to the levels). To this point, everything works fine. Now, I'm facing <missing> - values in the dynamically generated columns and I have to replace these with 0. I don't have a lot of experience with using python, my guess is, that I have to do something like this:
if i = '<missing>':
i=0
But I really don't know the exact syntax nor where to put this (I guess somewhere after "for i, type in enumerate(self.Types, 3):"). Any help would be greatly appreciated 🙂