error: how to deal with TypeError: NDFrame.to_csv() 'line_terminator' with Python snippet

Hello,
I’m having some issues with the python snippet node.

I’m using KNIME 5.2.0 and Windows 10…

My python snippet node can’t seem to get data out even if no operation is run (pyOut = kIn.copy()). The input data, even without modification from Python, get an error message:

ERROR Python Snippet 4:56 Execute failed: Error in processing: Traceback (most recent call last):
File “[path on my computer]vK1w03_analyze_7294712537195621547.py”, line 85, in
write_csv(r"[path on my computer]vK1w03_pyOut_python2knime_10228499832868678158.csv",pyOut)
File “[path on my computer]vK1w03_analyze_7294712537195621547.py”, line 79, in write_csv
pyOut.to_csv(f, header=False, date_format=‘%Y-%m-%dT%H:%M:%S.%f’, line_terminator = ‘\r\n’, escapechar = “\”, doublequote=False, quoting=csv.QUOTE_NONNUMERIC)
TypeError: NDFrame.to_csv() got an unexpected keyword argument ‘line_terminator’

Here is the “raw” data and the workflow.
CASlookup.xlsx (8.9 KB)
example error.knwf (14.8 KB)

The script I wrote initially works in python but it’s irrelevant because even a lack of operation causes the error. I have found some basic information about Panda and CSV writing in python but this does not help my case since it’s linked to the node.

Is this a bug? Is this caused by my data?
Any help would be greatly appreciated.

Hi @TheAlchemist47,

is there a specific reason why you use the nodes from KNIME Python Scripting extension – KNIME Community Hub and not from our currently quite actively developed KNIME Python Integration – KNIME Community Hub ? :slight_smile:

That one I can use just fine:
example_error_new.knwf (84.6 KB)

Does that help already?

Best regards
Steffen

1 Like

If this is supposed to be Pandas syntax the term would be lineterminator.

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html

Then you are using a community Python scripting extension. My suggestion would be to use the official one and read up how to use it.

You can send data directly from KNIME to Python and the other way round.

Then you can use your own .PY code (and Jupyter notebooks) from a KNIME Python node. You will have to make sure about the paths and data transfer. Here is a example how to do that.

And finally if you want the whole story about KNIME, Conda, Python and so on you can read my article:

3 Likes

@steffen_KNIME, @mlauber71 I’d say inexperience…

For some reason, the python scripting extension was already installed (maybe part of another package?) so I didn’t look for something else.
I will add the Python Integration!
Thanks for your help!

1 Like

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