Two flow variables in python source node, how to?

Hello all,
I would like to include two flow variables from a table in a python script, unfortunately without success. Here as an example: web scraping 5 keywords in 2 different websites.
Python_testing_flow.knwf (15.3 KB)

If I “hard code” one of the two variables, then everything works fine. With two flow variables it comes to the error message.

However, one flow variable has more data rows than the other. Could this be the problem? Or does this have to be solved with two tables? Then how?

I would be grateful for a little help!

@sabsab a loop will always use one row at a time. You already have a loop in your Python code so there is no need for another one.

You could collect your terms and urls and then provide them to the Python Script in one go:

You can then convert the collected strings into a list to use in your code:

urls = knio.flow_variables['url']
urls = [s.strip() for s in urls.split(",")]

search_terms = knio.flow_variables['keywords']
search_terms = [s.strip() for s in search_terms.split(",")]

kn_forum_67121_python_lists_loop.knwf (42.0 KB)

2 Likes

@mlauber71 thank you very much for the quick reply.
unfortunately i have to upgrade my python environment first to test it.
but assume that this is the solution :slight_smile:

This error was displayed:
ERROR Python Script (Labs) 3:165 Execute failed: Executing the Python script failed: Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘knime’

But i am using knime 4.6.4 and my python environment is certainly not optimal. I’m working on it, but it will still take time.

You can use the bundled Python environment:

Or you can install a Python/Conda version of your own and tell KNIME where to find it.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.