write csv file to a specified folder with Python node and running on KNIME Server

I have a workflow with Python (1=>1) node, and the workflow will be deployed on the KNIME Server. In Python node, I need to write a CSV file(df = test.csv) in a specified folder (/Data/).
My question is how to get the path of the folder and set it in df.to_csv() function to make sure the file is written to the folder. what’s the absolute path or other formats of the folder? is it knime://knime.mountpoint/Data? if yes, why the code below did not work:

Appreciate your help!

Hi @Hawk326040,

Unfortunately, the use of knime:// URLs is not supported in our Python scripting nodes at the moment (the only exception being the functions of the knime_jupyter module). A workaround would be to manually resolve the URL to a “real” file path outside the Python node and then feed that path into the node as a flow variable. Inside the Python node, you can access it via the flow_variables dictionary (panel on the left in the dialog). By default, the dictionary already contains the value of knime.workspace. So if saving the file to a workspace-relative location instead works for you, you could also make use of that value.

Alternatively, you could transfer the DataFrame df back to KNIME and write the data table using the CSV Writer node which does understand knime:// URLs.



Thanks, MarceIW.
I resolved this by df.to_csv(’./data/filename.csv’) in python code. This method will find the specified folder “Data”.