Python Script

Hello everyone!

I have a question related to a Python script node. I want to use this node to check a data of a column and send evaluated values to output table.
I don’t know anything about Python But I found the evaluation Script from the internet.
Is there any to say how to use this script by python script node. I know this should be so simple.
here is the python code I found:

import re
def is_valid(input: str) -> bool:
    if not re.search(r'^\d{10}$', input): return False
    check = int(input[9])
    s = sum(int(input[x]) * (10 - x) for x in range(9)) % 11
    return check == s if s < 2 else check + s == 11

Thanks , BR

Yes, please make yourself familiar with the usage of the Python Script node: KNIME Python Integration Guide

But this is not so simple if you never used Python before. You might need to setup a Python environment which contains the module for your import re and you need to write the functionality to create a new table which then contains one column whose content are the valid values of the incoming column.

Have fun exploring Python!
Steffen

3 Likes

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