Icon

kn_​example_​list_​split_​and_​duplicate

Split a list of IP adresses in one cell into individual ones and duplicate all other information from a line

Split a list of IP adresses in one cell into individual ones and duplicate all other information from a line

outer loop inner loop import knime.scripting.io as knioimport numpy as npimport pandas as pd# Sample data with IP addresses separated by commas in the first columndata = {'IP_Addresses': ['192.168.0.1, 192.168.0.2, 192.168.0.3','10.0.0.1, 10.0.0.2, 10.0.0.3','172.16.0.1, 172.16.0.2','192.168.1.1, 192.168.1.2','10.1.1.1, 10.1.1.2, 10.1.1.3, 10.1.1.4' ],'Dummy_Column_1': [100, 200, 300, 400, 500],'Dummy_Column_2': ['Data1', 'Data2', 'Data3', 'Data4', 'Data5'],'Dummy_Column_3': [True, False, True, False, True]}# Create a DataFramedf = pd.DataFrame(data)knio.output_tables[0] = knio.Table.from_pandas(df) Split a list of IP adresses in one cell into individual ones and duplicate all other information from a line outer loopSTARTby ,*_Arr*IP_Addressdynamic rename with "currentColumnName" nameinner loopENDouter loopENDip_adresses.tableChunk Loop Start Cell Splitter Column ListLoop Start Column Rename Loop End Loop End Table Reader outer loop inner loop import knime.scripting.io as knioimport numpy as npimport pandas as pd# Sample data with IP addresses separated by commas in the first columndata = {'IP_Addresses': ['192.168.0.1, 192.168.0.2, 192.168.0.3','10.0.0.1, 10.0.0.2, 10.0.0.3','172.16.0.1, 172.16.0.2','192.168.1.1, 192.168.1.2','10.1.1.1, 10.1.1.2, 10.1.1.3, 10.1.1.4' ],'Dummy_Column_1': [100, 200, 300, 400, 500],'Dummy_Column_2': ['Data1', 'Data2', 'Data3', 'Data4', 'Data5'],'Dummy_Column_3': [True, False, True, False, True]}# Create a DataFramedf = pd.DataFrame(data)knio.output_tables[0] = knio.Table.from_pandas(df) Split a list of IP adresses in one cell into individual ones and duplicate all other information from a line outer loopSTARTby ,*_Arr*IP_Addressdynamic rename with "currentColumnName" nameinner loopENDouter loopENDip_adresses.tableChunk Loop Start Cell Splitter Column ListLoop Start Column Rename Loop End Loop End Table Reader

Nodes

Extensions

Links