Consume file from Knime Workflow Directory

I need to place an excel file in Knime Workflow directory, and consume it using Python node. How do I do that so that It is transported along with Workflow artifacts and other folders to different environments and the path remains dynamic.
Please help!!

  1. Put the file in the workflow directory (if at all, this is mega-fiddly in KNIME GUI, so I just do it in the OS by going to the “workspace” folder)

  2. In KNIME, use the URL knime://knime.workflow/path/workflow.txt to access it (i.e. literal knime://knime.workflow + subpath)

  3. If you need to access it in a script, it probably makes sense to build an absolute file URL to the file upon execution – a while ago, I did this using the following absurdly looking node sequence, which would give me something like file:/Users/me/knime-workspace/workflow/path/workflow.txt or /Users/me/knime-workspace/workflow/path/workflow.txt:

    1. String to URI
    2. URL to File Path
    3. String to URI
    4. URI to String

Just ensure that these nodes re-run upon each execution, so that the path is always updated to the current system environment (hence the red input to the Table Creator)



@sujitnath84 about the transfer of data between KNIME and Python you might want to take a look at these examples to see paths variables in action like @qqilihq suggested.

1 Like

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