Open file on KNIME server in Python

I have a workflow where I’m creating an excel file and saving it to a location on KNIME server. Then, I want to access it in Python to do some formatting, etc. and resave. I cannot figure out how to reference the saved Excel file. Greatly appreciate any help with this!

Hi phahn,

What KNIME Server version are you currently using?

If you are using something above 4.11, I would suggest you to save the excel inside your workflow. Then you could use something similar to what is done in this workfliw: https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_python_excel_manipulate/kn_python_excel_manipulate

You could then use the extract context node to extract the path location, and then combine this with the excel name. Finally use it to reference your file.

Let me know, I can try to make a simple example if it helps!

Best wishes,
Ana

1 Like

Ana,

Thank you so much! This seems to be working!

Thanks,

Peyton

Hi @ana_ved, @phahn
please allow me to add in here…

I face the exact same problem, and I was wondering how can I “save a file inside the workflow”?
and even if it is large in size? is it the optimal solution?

Thanks!

Hi @ALAMRF,

Please let me chime in here: in any of the writer nodes, you can save the file inside of the workflow by specifying to save the file “relative to” “Current workflow data area” like in this example:

This works for any sized files if there is enough space on your server/wherever the workflow resides available.

Hope that helps and kind regards,
Lukas

Thanks Lukas for your reply,

unfortunately it does not seem to work with “Binary Objects to files” node, I get the error message:
Execute Failed: /< workflow folder >/< my workflow name >: Not a directory.

kindly lets move to my original post here: KNIME server path with Python script - #3 by ALAMRF

Thank You

Hey @ALAMRF,

the Binary Objects to Files node works a little different, as it expects a folder where it saves each of the input rows as a separate file. But you can select the workflow data area there as well and save the files to that - see my answer in the topic you posted.

Workflows as opened in e.g. the windows explorer are nothing but folders that contain files and folders that represent the nodes, their settings and data and connections. The “data area” of a workflow is simply a folder called “data” in that folder structure, which @ana_ved meant by saying “save the data inside of the workflow”. This way, the data area will come with the workflow.

Kind regards,
Lukas