Hey, I’m quite new to Knime and want to search for strings in a File. I have the following questions:
How should I read a Text in Knime? (Currently I’m using Load Text Files Node, is this the right way to do it?)
How can I search for Strings in a File? (Maybe with a Python Script?)
It would be great, if someone could give me a hand.
It depends on what exactly you need. The Load Text Files node is good, or you can use a Line Reader if you want to have one table row per text line instead. To figure out if a string cell contains a piece of text, you can use the indexOf() function in the String Manipulation node. It tells you exactly where in the string the text appears first. Is that enough, or do you need all occurrences?
thanks for the reply! It doesn’t matter where the string is in the file. It’s just important if the file contains the string. I have a list of strings in an excel file, so I’m using an Excel Reader to read those. How can I have multiple (2) inputs in a String Manipulation Node? My workflow should output a 0 or 1(or true or false) if one of the strings in the excel files are in the text file.
The String Manipulation node does not have multiple table inputs, but you can use the String Manipulation (Multi Column) if you write all the terms you are looking for into individual columns in your table. You can map those to the output of indexOf() and then aggregate with the Column Aggregator to check if any term is contained, if this is what you need.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.