All guides

Clean a content calendar CSV in n8n without losing campaign IDs

For
Solo marketers and small content teams who self-host n8n
Problem
Tidy an exported content calendar CSV while every campaign ID stays exactly as written
Tested with
n8n 2.42.7, self-hosted with npm, on Node.js 24.21.0
Tested on
Data
synthetic test files only

This workflow takes one content calendar CSV and writes a cleaned copy. It trims stray spaces and removes blank rows. In the CSV it writes, every campaign ID stays exactly as written, so 0042, 42 and CAFÉ-01 remain distinct. If the file has a problem the workflow cannot fix safely, such as two rows with the same campaign ID, it writes an error report instead of a cleaned CSV.

Tested: n8n 2.42.7, self-hosted with npm on Node.js 24.21.0, in the n8n editor, on 2026-10-13, with synthetic files. A script, not a person, operated the editor in a headless browser.

Also run, more narrowly: the kit's own copy of the workflow, by AI agents, on two of the synthetic files: on 2026-10-21 with n8n 2.42.7 installed the same way, from the command line; and on 2026-10-24 in the editor of an existing n8n 2.29.9 in Docker, through Chrome on macOS. Both gave the expected results. In the Docker run, the first download attempts failed (see Step 5).

Not tested: n8n Cloud, Windows, n8n running on macOS, a person using the editor, and real calendar exports. Docker, other n8n versions, desktop browsers (only Chrome on macOS) and an instance that already has workflows were covered only by the 2026-10-24 Docker run.

Before you start

  • A self-hosted n8n that you can open in a browser. Our main test used only n8n 2.42.7 installed with npm, signed in as the owner of a new instance. One narrower run by an AI agent used an existing n8n 2.29.9 in Docker (see How we tested).
  • Access to the files of the machine or container that runs n8n. You need it to put your CSV where n8n may read it (Step 1). The workflow reads and writes files there, not on the computer with your browser. You can download the result through the editor (Step 5).
  • Not tested on n8n Cloud. The n8n documentation says that on Cloud, files written by this node are not guaranteed to persist (S2).
  • The workflow file p1-csv-calendar-cleanup.workflow.json. It is in the n8n folder of the free sample kit. That copy differs from the file in our main test only in its note text and two comment lines. AI agents later imported this exact copy and ran it on two of the kit's test files, with the expected results (see How we tested).
  • Your CSV, UTF-8, comma-separated, with a header row that contains campaign_id, publish_date, channel and title. Other columns are kept.

Step 1: Put the CSV where n8n may read it

Since n8n 2.0, the Read/Write Files from Disk node may only use the .n8n-files folder in the home folder of the user that runs n8n, unless the administrator sets N8N_RESTRICT_FILE_ACCESS_TO (S2, S3). n8n does not create that folder for you.

On the machine that runs n8n, signed in as the user that runs n8n:

mkdir -p ~/.n8n-files/p1/input ~/.n8n-files/p1/output
cp calendar.csv ~/.n8n-files/p1/input/

The output folder must already exist, and n8n must be allowed to write to it.

In our test, n8n ran with the home folder /home/node, so the paths were /home/node/.n8n-files/p1/input/<file>.csv and /home/node/.n8n-files/p1/output. A file outside that folder was refused (see Troubleshooting).

If n8n runs in Docker, paths refer to the container's file system. Mount a folder from your computer into the container to share files with it (S2). Our only Docker run used a folder that the instance already allowed, not .n8n-files, so check where .n8n-files is inside your container.

Step 2: Import the workflow

  1. Open a new, empty workflow. In a new instance, the Overview page offers a Build a workflow card. Our main test used only a new instance; with existing workflows the entry point may look different.
  2. Open the workflow menu (… next to the workflow name), point to Import, choose From file, and pick p1-csv-calendar-cleanup.workflow.json.

The canvas then shows the workflow "P1 Clean content calendar CSV (contract 0.2.0)": eight nodes and a note.

In n8n 2.42.7 the workflow saved itself; there was no Save button. We did not click Publish; manual runs worked without it. The n8n documentation names the menu item "Import from File" (S1). The tested version shows Import, then From file.

Step 3: Set the two paths

  1. Double-click the File paths node.
  2. Set input_file to the full path of your CSV, for example /home/node/.n8n-files/p1/input/calendar.csv.
  3. Set output_folder to the existing output folder, for example /home/node/.n8n-files/p1/output.
  4. Press Tab to leave the field, then close the panel with × at the top right.

Use a plain absolute path. This field treats *, ?, [ ] and { } as pattern characters, so the path must not contain them (S2).

In our scripted run, closing the panel right after typing kept only the / of the last value; pressing Tab first avoided this.

After an earlier run, the OUTPUT side of this panel keeps showing that run's values until you run the workflow again. This is expected.

Step 4: Run it

Click Execute workflow at the bottom of the canvas. One of three things happens:

  • The file is accepted. The nodes up to Input rejected? turn green and n8n shows "Workflow executed successfully". One new file appears in output_folder, named <file name without .csv>.cleaned.<UTC time>-e<execution ID>.csv.
  • The file is rejected (a data problem). The run stops at Stop: input rejected. n8n shows "Problem in node 'Stop: input rejected'" with a message such as "Input rejected (E_DUPLICATE_ID, E_DUPLICATE_ID). No cleaned CSV was written. See …errors…json". The report <file name without .csv>.errors.<UTC time>-e<execution ID>.json lists each problem with its record numbers. No cleaned CSV is written.
  • The workflow could not read the file (a setup problem). The run stops at Read calendar file, and n8n shows "Problem in node 'Read calendar file'". Nothing is written. See Troubleshooting.

Each run writes a new file with its own name, so earlier results are not overwritten. The number after -e is the execution ID. The Executions tab shows the same ID (for example "ID#5") for the selected execution.

Step 5: Download the result

Right after the run, with the workflow still open:

  1. Double-click the Write output file node.
  2. In the OUTPUT panel on the right, select Binary if it is not already selected. The card shows the file name, type and size.
  3. Click Download in that OUTPUT panel. The INPUT panel on the left shows the same file with its own Download button; we tested the one in the OUTPUT panel.
  4. Close the panel with ×.

In our main test, the browser received the file under the name it has in output_folder, for example valid_basic.cleaned.20261013T043039Z-e1.csv. Where the file is saved depends on your browser's settings. That test used a headless browser, which has no download bar and no "Save as" dialog. For the doubled extension that Chrome showed in the narrower run by an AI agent, see the end of this step.

This also works for a rejected file. The run stops at Stop: input rejected, but Write output file has already written the error report. Its OUTPUT panel offers the .errors…json report for download.

The download is the copy of the file that n8n stored with the run. In our main test, each downloaded file was byte-for-byte identical to the file written to output_folder, and passed our contract checker. The file also stays in output_folder on the machine that runs n8n.

If the run stopped at Read calendar file, there is nothing to download: Write output file did not run.

In our main test, we used Download only right after each run, in the same editor session. In the narrower run by an AI agent (n8n 2.29.9 in Docker, Chrome on macOS), the first Download right after each run failed: Chrome showed "Blocked by your organization" and a file name with a doubled extension, such as .csv.csv. We have not found the cause. A second attempt saved both files with a single extension, and both matched the files that n8n wrote: the error report from the same OUTPUT panel, and the cleaned CSV from that run in the Executions tab (the run, then Write output file, OUTPUT, Download). The cleaned CSV was not downloaded again from the OUTPUT panel, so a direct download right after a successful run was not shown to work in that setup. That is our only download from the Executions tab. We did not test downloading after reloading the page or with the View button.

What our test run produced

Input (synthetic) Execution What happened Written to output_folder and downloaded
valid_basic.csv 1 Success valid_basic.cleaned.20261013T043039Z-e1.csv (377 bytes), equal to the expected output
valid_multiline.csv (line breaks inside cells) 2 Success valid_multiline.cleaned.20261013T043049Z-e2.csv (312 bytes), equal to the expected output
duplicate_ids.csv 3 Rejected at "Stop: input rejected" duplicate_ids.errors.20261013T043058Z-e3.json (627 bytes; IDs 0101 and 0102 each appear twice); no CSV
A path to a file that does not exist 4 Error in "Read calendar file": "No file(s) found" Nothing
A file outside ~/.n8n-files 5 Error in "Read calendar file": "Access to the file is not allowed." Nothing

For example, the row 42,2026-11-03, email ,Weekly notes ,team-b became 42,2026-11-03,email,Weekly notes,team-b, and 0042 stayed 0042.

A separate checker script, which is not part of the workflow, judged the three written files and the three downloads against the contract. All six passed.

Troubleshooting

There are two kinds of failure.

  • The workflow could not run on your file. These are setup problems. The run stops before the cleanup step and writes nothing.
  • The workflow ran and rejected your file. These are data problems. The run writes an error report but no CSV.
Message Meaning What to do
"Problem in node 'Read calendar file'" with "No file(s) found" input_file does not point to an existing file. Nothing was written. Check the path, file name and folder.
"Problem in node 'Read calendar file'" with "Access to the file is not allowed." The file is outside the folder n8n allows (~/.n8n-files by default). Nothing was written. Move the file into ~/.n8n-files. Widening N8N_RESTRICT_FILE_ACCESS_TO lets file nodes in every workflow on the instance reach more of the machine, so treat that as a security decision.
"Set input_file and output_folder in the "File paths" node." * A path is empty, or the output folder is only /. Fill in both values and press Tab before closing the panel.
"Expected exactly one input file…" * The path matched several files, usually because of a pattern character. Use one plain file path.
"Problem in node 'Stop: input rejected'" with "Input rejected (E_…)" The CSV broke a rule. The .errors…json file shows which rule and where. Fix the source data, export it again and run the workflow again. The workflow removes only blank rows and never drops campaign records or changes their IDs to make a file pass.
An "n8n Assistant" page appears after you create the account Part of first-run setup in n8n 2.42.7. To skip it, select Set up later in Settings.

* These messages come from the workflow's own checks in Validate and clean CSV. They were not triggered in the test run described here.

Limits

  • One CSV per run. Comma-separated values, UTF-8 only.
  • Each cell may hold up to 131,072 characters (Unicode code points). Spreadsheet apps may allow fewer.
  • Header names are matched exactly, including case (after trimming spaces).
  • Only spaces, tabs, line breaks and no-break spaces at the start and end of a cell are trimmed. Campaign IDs are never trimmed; an ID with a leading or trailing space is rejected.
  • IDs are kept exactly as written in the CSV file the workflow writes. We did not test opening or importing that file in a spreadsheet app, so we make no claim about how such apps treat the IDs.
  • Tested only as described at the top, and only with synthetic files.

How we tested

  • AI agents ran these tests, not a person. In this guide, "we" means Tracetern.
  • Main test, 2026-10-13: n8n 2.42.7 and Node.js 24.21.0 were installed with npm from a pinned lock file, with n8n's default binary data mode. The test runs had no internet access.
  • A Playwright script operated the editor in headless Chromium 141 on a new instance, signed in as its owner. It took Steps 2 to 5 through the editor's own menus, panels and buttons.
  • The input and output folders were prepared ahead of time with the layout from Step 1. The commands in Step 1 were not run as shown.
  • The written files were copied out of the test environment and checked by the contract checker. Each downloaded file was compared byte for byte with the written file of the same run.
  • The main test used the workflow file before its note text and two comment lines were changed for the kit. In two later runs, the kit's own copy was run on valid_basic.csv and duplicate_ids.csv only, once per file in each run.
  • 2026-10-21: with n8n 2.42.7 and Node.js 24.21.0 installed the same way, the kit's copy was imported and run from the n8n command line, not the editor. The cleaned CSV was byte for byte the expected output, and the error report listed the expected duplicate IDs.
  • 2026-10-24, different setup: a different AI agent operated Chrome on macOS. It downloaded the kit from our free sample page, imported the workflow through the editor of an existing self-hosted n8n 2.29.9 that runs in Docker (Node.js 24.16.0) and already had other workflows, and ran each file once with Execute workflow. The input files were in a folder that the instance already allowed. The AI agent compared the results with the expected files on the server, with the same outcome as above. The downloads are described in Step 5. These results come from that AI agent's written report; there are no screenshots.
  • The run records are kept privately: screenshots and logs of the main test, logs of the 2026-10-21 run and the AI agent's report of the 2026-10-24 run. They are not part of this article.

Sources

On 2026-10-13 we read the official n8n documentation from its source repository (n8n-io/n8n-docs, commit aa9e7bd, 2026-10-12), because the rendered pages could not be opened from the test environment. On the same day, a separate AI agent checked the rendered pages listed below. Its findings matched what we read in the repository.

Disclosure

Created with AI assistance. Tested with synthetic CSV files in the environment described above.