Python indentation level

Hi all,

first of all, I’ve just recently started playing around with python and the corresponding node in Knime. So basically, I had a python batch, which read a file, made some graph magic and wrote a new excel file. Now, I have a mini db for testing and I store my data there – no more excel files needed. That is why I want to change the python code so that it can work with the input from the db.

After a while, I managed to get rid of all errors and the node runs now. But, I somehow managed to mess up the indentation levels in the code -> The result is 0 [,1,] :frowning:

Could someone please take a look and hopefully point me out my mistakes.

Hello @nooby,

I’m not sure exactly what you are trying to achieve here, so it is tough to troubleshoot. What is the output you are trying to get here?

-Stephen

Hi @srauner,

my problem ist that the graph is empty and does not get the values from the columns. Thus, the result is 0 [,1,].

Cheers,
nooby

@nooby,

Can you send me the workflow in question so I can test?
If not, a small subset of data and the script as text would be helpful.

-Stephen

1 Like

Thanks in advance, Stephen.

PythonToDO.knwf (10.1 KB)

@nooby,

I’m not sure exactly the issue, but I don’t think it is related to the indentation of the code.
The error looks to be coming from within the ‘for row in df.itertuples(index=False):’ segment of the code (row 29).

If you look at the outputs during the loop, the value of df.columns.get_loc(‘Parent’) will always be 1, so there may be some overwriting happening here?

-Stephen

1 Like

Hi @srauner,

I’ll give it a look. Thanks for the tip.

Cheers