Python Snippet: Returns more rows than in input or error

And these additional rows are all full of missing values.

My suspicion is that the issue is caused by the data. One column contains base64 encoded data. This is then used by the library in python to convert to a format usable in Knime (smiles). Python code:

from ChemScript12 import *

pyOut = kIn

pyOut["SMILES"] = []

for cdx in kIn["CDX"]:

    m = StructureData.LoadData(cdx)

    if m is not None:

        pyOut["SMILES"].append(m.WriteData('smiles'))

    else:

        pyOut["SMILES"].append('')

 

If I remove the else I get the correct number of rows but an error message in the KNIME console:

ERROR  PythonSnippetNodeModel            Traceback (most recent call last):

ERROR  PythonSnippetNodeModel              File "C:\Temp\analyze7810475448194310407.py", line 226, in <module>

ERROR  PythonSnippetNodeModel                write_csv(r"C:\Temp\python2knime1577487205388145628.csv", pyOut, True)

ERROR  PythonSnippetNodeModel              File "C:\Temp\analyze7810475448194310407.py", line 195, in write_csv

ERROR  PythonSnippetNodeModel                value = column[current]

ERROR  PythonSnippetNodeModel            IndexError: list index out of range

What am I doing wrong?

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