HumanFirst icon

HumanFirst

Call HumanFirst playbook API

Overview

This node provides multiple operations to interact with the HumanFirst API, including managing playbooks, prompts, importing CSV files or documents, running pipelines, and transforming data formats. Specifically, the "Add Column to CSV" operation takes an input binary CSV file, appends one or more new columns with constant values to each row, and outputs the modified CSV as binary data. This is useful when you want to enrich existing CSV data by adding additional metadata or fixed-value columns without manually editing the file.

Practical examples:

  • Adding a "Source" column with a fixed value to track where the CSV data originated.
  • Appending a "Status" column with a default status for all rows before further processing.
  • Enriching exported CSVs from other systems with extra context columns for downstream workflows.

Properties

Name Meaning
Columns to Add One or more pairs of column name and column value to append to the CSV.
Delimiter The delimiter character used in the CSV file (default is comma ,).

The Columns to Add property is a collection allowing multiple entries, each specifying:

  • Column Name: The header name of the new column to add.
  • Column Value: The constant value to insert in every row under this new column.

Output

The output contains the modified CSV file as binary data with the same MIME type (text/csv) and filename preserved or set to "modified.csv" if not originally present.

The JSON output includes a columnIndices object mapping each column name (original plus added) to its zero-based index position in the CSV header row.

Binary output structure:

  • Property name: csv
  • Fields:
    • data: Base64-encoded string of the updated CSV content.
    • fileName: Original or default filename with .csv extension.
    • mimeType: "text/csv"

Dependencies

  • Requires an API key credential for the HumanFirst API to perform other operations (not specifically needed for the CSV column addition).
  • Uses Node.js Buffer and stream utilities internally for encoding/decoding CSV data.
  • No external libraries beyond those bundled with n8n are required for the CSV column addition operation.

Troubleshooting

  • Error: "No binary.csv found to modify"
    Occurs if the input item does not contain a binary property named csv. Ensure the previous node outputs a binary CSV file under the expected property name.

  • Malformed CSV after modification
    If the delimiter is incorrect or inconsistent with the input CSV, the output may be malformed. Verify the delimiter matches the CSV format.

  • Empty lines at the end of CSV
    The code trims empty trailing lines but ensure your CSV does not have unexpected blank lines that could affect parsing.

  • Multiple columns with the same name
    Adding columns with duplicate names can cause confusion in downstream processing. Use unique column names.

Links and References


If you need details on other operations or resources, please specify!

Discussion