Xpath Collection Cell output to str for Python Script

I am trying to generate a word count using python scripting for pulling a word count from a web page, but it appears the Python script can’t detect the variable type, and I assume it’s because of the XPath output from the previous node. I’ve looked through the ‘to string’ conversions, but I can’t determine what the actual output from XPath is. Screenshows below:

Xpath Configuration:

Python Script:


Does someone have an idea of what I am doing wrong here and how I can fix this?

Also I found this Vernalis community Node for collection to string but I am having an issue installing it. It gives the following error:

Cannot complete the install because one or more required items could not be found.
Software being installed: Vernalis KNIME Nodes 1.36.2.v202301131541 (com.vernalis.knime.feature.feature.group 1.36.2.v202301131541)
Missing requirement: Vernalis custom KNIME nodes package 1.36.2.v202301131541 (com.vernalis.knime 1.36.2.v202301131541) requires ‘osgi.bundle; org.knime.workbench.core [3.0.0,5.0.0)’ but it could not be found
Cannot satisfy dependency:
From: Vernalis KNIME Nodes 1.36.2.v202301131541 (com.vernalis.knime.feature.feature.group 1.36.2.v202301131541)
To: org.eclipse.equinox.p2.iu; com.vernalis.knime [1.36.2.v202301131541,1.36.2.v202301131541]

1 Like

Your body column currently looks like type collection, set or list as you use collection cells.These elements can be converted to multiple rows using the ungroup node. I assume python needs " normal" KNIME tables to process.
You might want to share your workflow with sample data here for the community to help better

1 Like

Here is the sample workflow:

URL_word_count_extractor_sample1.knwf (2.7 MB)

I could have the rows split, but I need them together so that I can get a word count of a given page from the flow. So if I can export them as separate rows and them combine these rows, that may work as well.

Multiple rows can be combined as text when using groupby node and aggregation method concatenate.

This worked. I split the query by row and then used GroupBy to aggregate the rows. I have a working word count now. Thanks!

1 Like

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