Reference files on local file system that are synced from Box.com in local knime workflow

I’m trying to use the knime:// protocol to read files that live outside of knime workflows. My team uses Box.com and we would like to be able to reference files in our knime workflows that live in the synced Box.com folder on each of computers. Currently we have some workflows that read files from absolute paths that are hard-coded and include individual users names (C:\Users\username), but I would like use relative file paths to read these files instead. We also have users on Linux that would like to be able to run the same workflows.

I have tried reading this article: https://www.knime.com/knime-introductory-course/chapter2/section1/absolute-and-relative-paths-knime-protocol, and when I try to use the knime:// protocol in a File Reader node I see the following error:

I/O Error while analying file: Can’t access ‘knime://knime.workflow/…/…/Documents/test.xlsx’. (Leaving the mount point is not allowed for workflow relative URLs).

Is there a way to do what I’m trying to do here?

1 Like

@BrianCaffey, is there a reason why you’re using 3 dots (instead of 2) in your file path when you want to go up a level?

Hi @BrianCaffey and welcome to the KNIME forum,

You can use the global variable “knime.workspace”. For example, the expression below in the String Manipulation node gives you the absolute path to the directory in which the KNIME workspace exists which is the “Documents” folder on a standard local installation:
regexReplace($${Sknime.workspace}$$, "\\\\[^\\\\]*$", "")

you can add anything to the path:
regexReplace($${Sknime.workspace}$$, "\\\\[^\\\\]*$", "\\\\test.xlsx")

:blush:

1 Like

Sorry, those should both be .., not ....

Thanks for your reply. Shouldn’t I be able to reference a file in Documents by:

knime://knime.workflow/../../Documents/text.xlsx

I’m not sure what I would do with your expression. I’m trying to use a simple File Reader node. What would I put in the box that says Enter ACSII data file location?

1 Like

You can use the String Manipulation (Variable) node and use the expression to create the file location as a flow variable for the File Reader node (or any other nodes).

:blush:

Nothing! After creating the location path using the “knime.workspace” variable in the String Manipulation (Variable) node, pass the variable to the File Reader node and click the small button next to the “Browse” button and assign select the variable.

Here is an example. Assumes you have a file (test.csv) in the directory where your KNIME workspace exists as well:

knime_workspace.knwf (25.8 KB)

:blush:

I think you need to configure the file reade with an absolute path before selecting a flow variable path.

Steve

Hi @BrianCaffey,

welcome to KNIME Community!

Here is related topic that might help:

Br,
Ivan

So far, Knime seems to have no easy solution for this very common requirement.

Non easy solutions:

  • move your files inside the workspace and use relative paths
  • use absolute paths
  • use flow variables within the reader nodes and use string manipulation on flow variables (workspace directory) to build your path

Easy solutions:

  • I think there is the option to use mount points if you have the paid server version but this is my interpretation without having tried it out

In my opinion Knime is making it to difficult and should simply allow paths relativ to the current workspace that are outside the workspace.

1 Like

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