Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
@david_rÂ
will its a list of stringsÂ
The value of "d" is: o'40QFM1818918004', '40QFM2615910278', '40QFM1322416717', '40QFM2059919336', '40QFM1539918653']
its very huge there a sample
Should all features have the tag_list list? If you're happy to ignore cases where the list doesn't exist you could use. Or you could just test to exclude prior to the pythoncaller
    s = str(feature.getAttribute('partial'))
    d = feature.getAttribute('tag_list{}.TAG_ID')
    if d:
        matches = Ii for i in d if s in i]
@david_rÂ
will its a list of stringsÂ
The value of "d" is: Â'40QFM1818918004', '40QFM2615910278', '40QFM1322416717', '40QFM2059919336', '40QFM1539918653']
its very huge there a sample
I'm guessing you have more than one feature? Do they all have a list of values, or does one or several of them not have a list value?Â
Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
no this list is made with listbuilder because i didn't how to do it any other wayÂ
no this list is made with listbuilder because i didn't how to do it any other way
Before your Python code, try inserting a ListElementCounter on tag_list{}.TAG_ID, then a Tester to check that the count of elements > 0. If you have any elements where the count is 0, then there's the problem.
Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
its > 0 it passed the tester
and i tried to use ListElementCounter too loop with while but it also gave me some error about 'NoneType' Â
its > 0 it passed the tester
and i tried to use ListElementCounter too loop with while but it also gave me some error about 'NoneType'
If your list has sub_elements it's possible for it to pass the ListElementCounter test whilst still not having a value for tag_list{}.TAG_ID depending on how the list has been built
Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
only one attribute is add in the list on ListBuilder parameters if that's what you meanÂ
If you want to find which features do not have any tag_list{}.TAG_ID values you could do the following in a python caller
Â
import fme
import fmeobjects
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        s = str(feature.getAttribute('partial'))
        d = feature.getAttribute('tag_list{}.TAG_ID')
        if d:
            pass
        else:
            self.pyoutput(feature)
    def close(self):
        pass
only one attribute is add in the list on ListBuilder parameters if that's what you mean
Can you share a screenshot of your listbuilder?
Seems like the value of 'd' is None at some point, for some reason.
Try to comment out the third line and add the following to see what the value actually is while the workspace is running:
print('The value of "d" is: ' + str(d))
yeah sure here
Should all features have the tag_list list? If you're happy to ignore cases where the list doesn't exist you could use. Or you could just test to exclude prior to the pythoncaller
    s = str(feature.getAttribute('partial'))
    d = feature.getAttribute('tag_list{}.TAG_ID')
    if d:
        matches = Ii for i in d if s in i]
i tried this but it skips everything like the list is with empty elements @ebygommÂ
i think the problem is that i put the list(coming from listbuilder) as input and the pythoncaller treating it as the firs input not something i need to use with each record
Â
@ebygomm @david_r what should i do to make the list as a variable usable with every record in paythoncaller
i think the problem is that i put the list(coming from listbuilder) as input and the pythoncaller treating it as the firs input not something i need to use with each record
Â
@ebygomm @david_r what should i do to make the list as a variable usable with every record in paythoncaller
Can you share a screenshot of the pythoncaller?
Is it possible that your code is located under the "__init__" method (executed once at startup) rather than under the "input" method (executed once for every input feature)?
See the screenshot posted by @ebygomm below.
Â
Â
Is it possible that your code is located under the "__init__" method (executed once at startup) rather than under the "input" method (executed once for every input feature)?
See the screenshot posted by @ebygomm below.
Â
Â
no it is under input
Can you please post a screenshot of the entire PythonCaller transformer configuration? Or even better, post a minimal sample workspace that demonstrates the problem.
I couldn't solve the problem so i made a pythoncaller after the listbuilder and in it i store the list as a global variable and it worked
This error means that python is trying to iterate over a None object. With Python, you can only iterate over an object if that object has a value. This is because iterable objects only have a next item which can be accessed if their value is not equal to None. If you try to iterate over a None object, you encounter the TypeError: ‘NoneType’ object is not iterable error.
Â
For example, list.sort() only change the list but return None.Â
Â
Python's interpreter converted your code to pyc bytecode. The Python virtual machine processed the bytecode, it encountered a looping construct which said iterate over a variable containing None. The operation was performed by invoking the `__iter__` method on the None. None has no` __iter__` method defined, so Python's virtual machine tells you what it sees: that NoneType has no` __iter__` method.
Â
Technically, you can avoid the NoneType exception by checking if a value is equal to None before you iterate over that value.
Â
Â
Â
This error means that python is trying to iterate over a None object. With Python, you can only iterate over an object if that object has a value. This is because iterable objects only have a next item which can be accessed if their value is not equal to None. If you try to iterate over a None object, you encounter the TypeError: ‘NoneType’ object is not iterable error.
Â
For example, list.sort() only change the list but return None.Â
Â
Python's interpreter converted your code to pyc bytecode. The Python virtual machine processed the bytecode, it encountered a looping construct which said iterate over a variable containing None. The operation was performed by invoking the `__iter__` method on the None. None has no` __iter__` method defined, so Python's virtual machine tells you what it sees: that NoneType has no` __iter__` method.
Â
Technically, you can avoid the NoneType exception by checking if a value is equal to None before you iterate over that value.
Â
Â
Â
I'll just add that not all objects are iterable, e.g. int and float types aren't iterable, meaning that simply checking for "not None" isn't quite enough. See also:
https://www.geeksforgeeks.org/how-to-check-if-an-object-is-iterable-in-python/
This error indicates an attempt to access an indexing functionality on an object that does not support it. Specifically, you are trying to subscript an object that you assume to be a list or dictionary, but it is actually None. NoneType is the type assigned to the None object, which signifies the absence of a value. For instance, a function that does not explicitly return a value will default to returning None. When you encounter the error message "'NoneType' object is not subscriptable," it means that you are using square bracket notation (object[key]) on an object that does not define the getitem method required for indexing.
Â
A subscriptable object refers to any object that supports the getitem special method, such as lists or dictionaries. It is an object that can record and store operations performed on it as a "script" that can be replayed. However, in your case, you are attempting to subscript an object that you believe to be a list or dictionary, but it is actually None. NoneType is the type assigned to the None object, which signifies the absence of a value. For instance, when a function does not explicitly return a value, it defaults to returning None. When you encounter the error "'NoneType' object is not subscriptable," it means that you are using square bracket notation (objecttkey]) on an object that does not define the getitem method required for indexing. It is worth noting that certain methods, like sort(), which only modify a list, do not have a printed return value and instead return the default None. This is a design principle applied to all mutable data structures in Python.
Â
Â