Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

File Paths and Alteryx

SophiaF
Alteryx
Alteryx
Created

You deal with paths every day to browse to your data. This topic delves into detail about paths, defining the different types, and how Alteryx manages them.
 

Paths and pathnames

 

Path

 

A path is a slash-separated list of directory names followed by either a directory name or a file name. A directory is the same as a folder.

E:\Data\SavedThings            (path terminating in a directory name)
E:\Data\SaveThings\workflow.yxmd  (path terminating in a file name)


Pathname

 

On occasion, you may see the term pathname or path name. Path, pathname, and path name are synonymous.

 

Forward versus backward slashes

 

The Windows convention is to use a backward slash (\) as the separator in a path. 


Backward slash in scripting

 

Programming languages that have their roots in UNIX and the C programming language, such as Python, treat the backslash (\) as the escape character. For example, \n signifies a carriage return. Since paths can contain backslashes, you need to prevent backslashes from being used as the escape character. A common technique is to escape the backslash, as follows:

thePath = "E:\\data\\london\\gherkin"

Another way is to convert paths into Python raw strings using the r directive, as shown below. This instructs Python to ignore backslashes.

thePath = r"E:\data\london\gherkin"

 

Absolute and relative paths


Absolute, or full, path

 

An absolute, or full, path begins with a drive letter followed by a colon, such as D:.


Relative path

 

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

In the example directory structure below, assume you used Windows Explorer to navigate to D:\Data\Testing\App. After navigating to this directory, a relative path will use D:\Data\Testing\App as the current directory (until you navigate to a new directory, at which point the new directory becomes the current directory). The current directory is sometimes referred to as the root directory.

image.png
If you wanted to navigate to the Con directory from the current directory (App), you could type the following in the Windows Explorer Address box:

..\Con

Windows Explorer would navigate to D:\Data\Testing\Con. A few more examples using D:\Data\Testing\Con as the current directory are below:

..               (D:\Data\Testing)
..\..            (D:\Data)
..\..\Final      (D:\Data\Final)
.                (D:\Data\Testing\Con - the current directory)
..\..\.\Final\..\Testing\.\Con    (D:\Data\Testing\Con)
 

Absolute and relative paths in Alteryx


When working on an Alteryx workflow, you can specify that paths will be stored as relative paths. To set this option, look under the Options menu  > Advanced Options > Workflow Dependencies. Here, you can specify whether to store absolute, relative, or UNC paths.

image.png

When you save the document with relative paths, the application converts paths into relative paths (using the dot/double-dot notation) relative to the location where you stored the document (the current directory). For example, if your document is stored in

D:\Workflows\HR\org_chart.yxmd

and one of the files you use in your workflow is

D:\Data\Final\contractors.xlsx

setting the "All Relative" options would give the following:

..\..\Data\Final\contractors.xlsx

If you click the "All Absolute" button, Alteryx converts the stored relative path from the dot/double-dot notation back into the absolute path representation.

Only paths on the same disk are converted

Relative paths cannot span disk drives. That is, if the workflow is on drive D, you cannot use relative paths to navigate to a directory on drive E. When you store your map document using relative paths, only those paths that are on the same drive are converted.

 

Why use relative versus absolute paths?


Using absolute paths, the following are true:

  • You can move the workflow anywhere on your computer and the data will be found when you reopen the document or tool.
  • On most personal computers, the location of data is usually constant. That is, you typically don't move your data around much on your personal computer. In such cases, absolute paths are preferred.
  • You can reference data on other disk drives.

Using relative paths, these adjustments are necessary:

  • When moving a workflow, you must also move the referenced assets (data, macros, etc.).
  • When delivering workflows to another user, relative paths should be used. Otherwise, the recipient's computer must have the same directory structure as yours.

For example, consider the directory structure below. In this example, D:\Tools\Prod\mod.yxmd contains a tool that uses D:\Tools\Storage\output.txt.
image.png

Using absolute paths, if you moved the workflow from D:\Tools\Prod\ to a different disk, such as E:\Final\Prod, ArcGIS will find D:\Tools\Storage\output.txt and everything will work fine. If, however, you use relative paths, Alteryx will not find the file and the workflow will error. You will have to open the workflow and enter the correct path to the file.

On the other hand, if you use relative paths, you can simply copy the folder D:\Tools anywhere on anyone's computer and everything will work. This won't work if you use absolute paths, because the recipient could copy the folder to F:\NewTools and the path D:\Tools\Storage\output.txt won't exist on their computer.

Summary

  • Relative paths cannot span disk drives.
  • Absolute paths work best when data isn't moved, which is typical for disks on a personal computer.
  • Relative paths work best when you're delivering documents and data to another user.
  • Relative paths use dot/double-dot (. and ..) notation. You can enter relative paths with this notation in Windows Explorer or at the Windows command prompt.
  • Relative paths are relative to a current directory, which is the location of the workflow.
 

UNC paths

 

UNC stands for Universal (or Uniform or Unified) Naming Convention and is a syntax for accessing folders and files on a network of computers. The syntax is as shown:

\\<computer name>\<shared directory>\

followed by any number of directories and terminated with a directory or file name.

For example:

\\domainfolder\public\apples.csv
\\monitors\shared_stuff\rocker\stand

The computer name is always preceded by a double backward slash (\\).

In UNC, the computer name is also known as the hostname.

These are a few rules for UNC paths:

  • UNC paths cannot contain a drive letter (such as D).
  • You cannot navigate to directories above the shared directory.

In Alteryx, you can use a UNC path anywhere a path is requested. This is particularly advantageous for shared data on a local area network (LAN). Data can be stored on one computer and everyone with access to the computer can use the data, as long as the computer is not turned off or removed from the network.

In Windows, you can share a folder so that other users on your local area network can access it. In Windows Explorer, right-click a folder, click Properties Sharing > Share then follow the instructions on the dialog box that opens.



Additional Resources

 
Comments
JMB001
8 - Asteroid

Hello,

 

I'm not grasping this section below. Since the final relative path seems to be saying "parent directory\parent directory\Data\Final\contractors.xlsx" is where you will always be able to navigate to in order to find that file. But a) There are not two parent directories above \Data\, only one, "D:\" and b) even if those two directories are meant to mean from the current directory of the ".yxmd" file, navigate up two parent directors and then back down until you find the .xlsx file, it wouldn't make sense since the ."yxmd" file exists at the same level of hierarchy, 3 levels down from the root drive, and not 4. What am I missing?

 

Thanks,

Joe

--------------------

 

When you save the document with relative paths, the application converts paths into relative paths (using the dot/double-dot notation) relative to the location where you stored the document (the current directory). For example, if your document is stored in

D:\Workflows\HR\org_chart.yxmd

and one of the files you use in your workflow is

D:\Data\Final\contractors.xlsx

setting the "All Relative" options would give the following:

..\..\Data\Final\contractors.xlsx