Skip to main content
Solved

Getting lists in PythonCaller

  • September 5, 2017
  • 7 replies
  • 1221 views

Forum|alt.badge.img+1

Hi,

I am using FME Desktop 2017 and would like to know if there is a way to get a list that I have generated in my FME Workflow, into the PythonCaller, in a similar way to how you use 'getAttribute' function feature.getAttribute(x) to get a normal attribute into the PythonCaller.

Thank you for your help in advance.

Best answer by jdh

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • Best Answer
  • September 5, 2017

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.


danilo_fme
Celebrity
Forum|alt.badge.img+52
  • Celebrity
  • September 5, 2017

Hi @aquamarine,

I created a Workspace that show the print values from a List ( _list{}.names ) in Log file using the PythonCaller:

Thanks,

Danilo


Forum|alt.badge.img+1
  • Author
  • September 5, 2017

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.

That's exactly what I needed!

 

Thank you @jdh

 


Forum|alt.badge.img
  • January 10, 2018

Hi @aquamarine,

I created a Workspace that show the print values from a List ( _list{}.names ) in Log file using the PythonCaller:

Thanks,

Danilo

Hi all

 

I am getting from Excel a column called Name,

 

after I built lists with Listbuilder ,

 

but I have an error in my pythoncaller,

 

please provide some feedback

 

 


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • January 10, 2018
Hi all

 

I am getting from Excel a column called Name,

 

after I built lists with Listbuilder ,

 

but I have an error in my pythoncaller,

 

please provide some feedback

 

 

If you inspect the features prior to the PythonCaller, does every feature have a value for _list{0}.Name?

 

 

You can try adding "if Nombres:" just prior to the for loop, so that there is no python exception if there list doesn't exist.

 

 

 


Forum|alt.badge.img
  • January 11, 2018
If you inspect the features prior to the PythonCaller, does every feature have a value for _list{0}.Name?

 

 

You can try adding "if Nombres:" just prior to the for loop, so that there is no python exception if there list doesn't exist.

 

 

 

 

Yes, the list has many values , I dont know is I can iterate the object..

 

@takashi , @david_r , @danilo_fme , @takashi

 

I am using FME 2016.1


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • January 11, 2018

 

Yes, the list has many values , I dont know is I can iterate the object..

 

@takashi , @david_r , @danilo_fme , @takashi

 

I am using FME 2016.1

There seems to be some white space at the end of the _list{}.Name attribute.