Skip to content

Lesson 5 ยท Reading and Writing Data

File Paths and Reading Multiple Files in KNIME

Use relative paths so workflows work on other computers, read a folder of files at once, track which file each row came from, and connect to cloud storage.

A workflow that reads C:\Users\anna\Desktop\orders.csv works on exactly one computer. This lesson shows how to point KNIME at files in a way that survives sharing, how to read a whole folder in one step, and how remote storage fits in.

Kinds of paths

KNIME describes a location with a type, an optional specifier, and a path. The main types are:

Type Meaning When to use
Local A path on this computer Personal experiments
Relative to Relative to the workflow, its data area, or the mountpoint Shared projects
Mountpoint A location in a named KNIME space Files kept in a space
Custom URL A URL such as a knime:// or web address Single files from a URL
Connected A file system provided by a connector node Cloud and remote storage

The workflow data area is a folder stored inside the workflow. Files kept there travel with the workflow when you move or share it, and are removed if you delete it. That is convenient for small reference files, but not for large or sensitive data.

Which path should I use?

Just me Local path is acceptable
A team Relative to workflow or space
Tiny lookup file Workflow data area
Cloud storage Connector node
1 / 2

Why relative paths matter

Suppose the project folder looks like this:

TEXT
reporting/
  monthly-report   (workflow)
  input/
    orders.csv

If the reader uses a path relative to the workflow, a colleague who copies the whole reporting folder gets a working workflow, wherever they put it. With an absolute local path, they must edit every reader.

Python Stand-in: building paths relative to a workflow folder

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The same relative text works from both base folders. This stand-in only joins text. KNIME has its own path rules, so use the file chooser in the reader dialog rather than typing by hand.

Reading many files at once

Imagine one CSV file per month: orders-2026-09.csv, orders-2026-10.csv, and so on. Older approaches needed a loop. Today, readers such as CSV Reader can use a Files in folder mode. You can then filter which files are included, for example only those with a .csv extension, and choose whether to include subfolders.

Turn on the option to append a path column. Every row then records which file it came from. That helps you trace odd values and detect a file that was read twice.

Files in one folder should have the same structure. If one month renames amount to total, the combined table gets gaps or the reader complains. Test what happens when a new column appears, and decide whether your workflow should accept it or fail loudly.

Python Stand-in: reading many files and recording the source

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The stand-in chooses to skip a bad file and print a warning. In production you might prefer to stop the run, since silently missing a month is a serious error.

Remote and cloud storage

To read from services such as Amazon S3, SharePoint, or Azure storage, you first add a connector node, often with an authentication node before it. You then connect it to the reader through a port that the reader can add for this purpose. The reader uses the connected file system just like a local one.

Keep credentials out of saved workflows. The best practices lesson explains safer ways to supply them.

Changing paths with variables

You will often want the file name to change each run, such as the latest month. A flow variable can overwrite the reader's path setting. You learn how in flow variables. Some older nodes still expect paths as plain text, and KNIME includes small conversion nodes between path and string values for that case.

A common error is a workflow that passes on your computer and fails for everyone else because of one absolute path. Before sharing, open each reader and check which path type it uses.

Filtering which files are read

A folder often holds more than the files you want: notes, old backups, temporary files created by spreadsheet programs. Use the file filter options to include only what you expect, for instance a specific extension or a name pattern. After execution, group the path column and count rows per file. That small summary answers three questions at once: which files were read, whether any file is unexpectedly small, and whether anything was read twice.

Check Why it matters
Number of files A missing month changes every total
Rows per file A tiny file may be a failed export
Unexpected names A backup copy can double the data

What happens when files change

Readers analyze structure when you configure them. If the files later gain or lose a column, behavior depends on the reader settings. You may prefer a workflow that stops with an error when the structure differs, because a silent change can produce wrong totals. In other cases, such as optional survey columns, you want new columns to flow through. Decide on purpose, and test both an extra column and a missing column before you rely on the workflow.

Output paths

Writers need the same care as readers. If a writer uses an absolute path on your Desktop, a colleague's run fails or writes somewhere unexpected. Use a relative output folder and make sure it exists, or enable an option that creates missing folders if your writer offers one. Check the overwrite setting too. Choosing to overwrite is convenient during development, but in a scheduled job it can replace last month's report without anyone noticing. Putting the period into the file name avoids most of that risk.

Practice task

Create a folder with three small CSV files that share columns, plus one text file that should be ignored. Read the folder, add the path column, and confirm the text file was excluded. Then move the whole project folder to another location and execute again. If it still works, your paths are portable.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which path choice best suits a project folder shared with colleagues?

    Relative paths keep working when the folder moves together.
  2. 2. Why append a path column when reading a folder of files?

    The source column helps with tracing problems and spotting duplicates.
  3. 3. What is the workflow data area?

    Files in the data area move and are deleted together with the workflow.
  4. 4. How do you read from cloud storage?

    Connected file systems are provided by connector nodes.

Summary

  • Paths have types: local, relative, mountpoint, custom URL, and connected.
  • Relative paths make workflows portable.
  • Read same-structure files from a folder and record the source path.
  • Watch for changed columns between files.
  • Remote storage uses connector nodes, and credentials should not be saved in workflows.

Next: Databases and Writing Data

Your progress is saved in this browser. No account needed.