Skip to main content

I have a python script that reads a set of values that we want to expose out of PythonCaller as a list; however, after several attempts, we are having issues outputting the list out of the Transformer. Running the script works outside of workbench, but having issues incorporating the script with FME. Debugging the script and writing to the log, we know the code is calculating the values for the list consisting a several attributes. And, the thinking is we are not formatting the list correctly or defining it. I have attached a simple workbench that contains a slimmed down script that we are trying to utilize to determine how to output a list at all. Any help in this regard is much appreciated.

 

Here is a part of the slimmed down script listing the nested loop we want to use and the List name we want to output:

 

  def input(self,feature):

     

    npts = 3

     

    # do a bunch of stuff with other input attributes to populate D

 

    C = /'X','Y']

    D = {'X':/2308759.15, 2308759.36, 2308759.60], 'Y': .10917108.40, 10917109.28, 10917110.13]}

       

    for i in C: # pass data to FME structured list called Survey{}

      for j in range(npts):

        d = str(D i]fj])

        feature.setAttribute('Survey{{{}}}.{}'.format(j,i),d)

        # print log to see if loop and format works

        msg = 'Survey{{{}}}.{}  {}'.format(j,i,d)

        fmeobjects.FMELogFile().logMessageString(msg)

 

    self.pyoutput(feature)

 

  def close(self):

 

 

Hi @rss808​ 

The workspace you shared does create the list attributes Survey{}.X and Survey{}.Y

Note that list attributes do not appear in table view of Visual Preview or Data Inspector. List attributes can be viewed in the Feature Information after selecting a feature.View list attributes in the Feature Information window of Visual Preview or Data Inspector


Hi @rss808​ 

The workspace you shared does create the list attributes Survey{}.X and Survey{}.Y

Note that list attributes do not appear in table view of Visual Preview or Data Inspector. List attributes can be viewed in the Feature Information after selecting a feature.View list attributes in the Feature Information window of Visual Preview or Data Inspector

Thanks @debbiatsafe​ for your response; I was expecting the list values to be attributes to expose in the Transformer configuration. Since I am not very familiar utilizing list attributes presented in the data inspector, can you please let me know if there is a method to make the Survey{}.X and Survey{}.Y values into attributes, so I can utilize further in a translation to create features like lines or points. I tried several List transformers, but these transformer require attributes. Or am I missing something?


Thanks @debbiatsafe​ for your response; I was expecting the list values to be attributes to expose in the Transformer configuration. Since I am not very familiar utilizing list attributes presented in the data inspector, can you please let me know if there is a method to make the Survey{}.X and Survey{}.Y values into attributes, so I can utilize further in a translation to create features like lines or points. I tried several List transformers, but these transformer require attributes. Or am I missing something?

If you type Survey{}.X and Survey{}.Y  into the attributes to expose parameter in the PythonCaller you should then be able to access the list in a List transformer, e.g. List Exploder or similar

imageIf you don't expose the list, although the list is present, it won't be selectable in a transformer


Reply