Skip to main content

I have a list of lists resembling this structure:

sublists = [[1,2,3],[4,5,6],[7,8,9]]

 

When I try to set this "list of lists" into a list attribute I get the following:

code -

feature.setAttribute('chunkList{}', sublists)

 

error -

Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.

Traceback (most recent call last):

 File "<string>", line 95, in input

TypeError: Could not convert attribute value to a supported attribute type.

Error encountered while calling method `input'

PythonCaller_Get_chunkList (PythonFactory): PythonFactory failed to process feature

 

  1. The goal is to have a list of 1000 unique IDs or less to feed into a reader
  2. I do not know how many lists there will be ahead of time so I need to dynamically break out the lists into individual lists of 1000 elements later in the workflow which is why I want 1 list of lists to start with.

 

 

 

Try something like

sublists =  =1,2,3],,4,5,6],,7,8,9]]
for n, item in enumerate(sublists):
    feature.setAttribute('chunkList{%s}.sublist{}' % n, item)

Result:

imageYou can then do a ListExploder on chunkList, if you need to have one feature per sublist.


Thanks for the quick response @david_r​, that did the trick! I did want each feature to have its own sub-list which I exposed and then concatenated, giving me the queries I will need for each set of records to fetch from a reader.

 

Sublists


Reply