Merge file

Describe the problem/error/question

I have one specific problem while merging two files in n8n. so basically i want to merge two separate files but they should be align vertically means file 1 should be above file 2 and both data should not be clashed. file on contains pure text data. so whats the solution here ?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @Abbasali_Sunasara

please, provide examples of what you are going to achieve. Currently, it’s not clear

so my first file is consist of tabular text for ex:- file 1 = A,B,C
and 2nd file contains processed data for ex:- file 2= 123

the file 1 should be above file 2 data and vertically aligned.
Screenshot 2024-02-15 155419

then this one should do the job. If the file1 (upper one) contains only one row with headers

The pinned data for file1:

    "value": [

The pinned data for file2:

    "value": [
    "value": [

let bifile = $items(‘bifile’);
let master = $items(‘master’)
let results = ;

let headers = bifile.shift().json.row

bifile.forEach(r => {
let row = {}
Object.entries(r.json.row).forEach(e => {
row[headers[e[0]]] = e[1]



for (const item of $input.all()) {

    let merchant_sku = item.json["marketplace_sku"];
    let quantity = item.json["Amz PO Qty"];
    let FC = item.json["FC"];

    FC = FC.replace(".csv", "")
           .replace(".xls", "")
           .replace(".xlsx", "")
           .replace(".tsv", "");

    let newdata = {
        "Merchant SKU": merchant_sku,
        "Quantity": quantity,
        "FC": FC,
        "prep owner": "seller",
        "Labeling owner": "seller",
        "Prep category": "Choose prep category"



// return results
let mergedData = […master, …bifile];
return mergedData;

here is my code

@Abbasali_Sunasara what is that code for? If you can include more detail and examples we will be able to help further.

master is file no.1
bifile is file no.2(which will be processed on below)
in new data i am adding new columns and dumping data from bifile
so after bifile is processed what i want to do is keep the master file data on top and below the processed data of file no.2

thx for the concern but i have already tried this way and unfortunately its not working for me.

Which bit isn’t working?

@Jon The @barn4k has sent me workflow in reply i’ve tried that but its not working

Hey @Abbasali_Sunasara,

Which bit isn’t working though, I have given it a test and the workflow seems to work ok. If you are something more specific it would be handy to have those extra details.

I want to merge two files without changing their index and unfortunately i cant share workflow because of some reasons.

Hey @Abbasali_Sunasara,

Are you able to make an example workflow maybe?

@Jon ok sure. here is demo workflow i have prepared and i have 2 files also and one result file. so i want upper content and lower content vertically aligned by merging two file that is shown in basically how i want to merge both file is in final result image.

here are 3 images one has upper part other has lower part and 3rd image has result of what i want

That one is not the typical structured CSV file, so the easiest way to merge files would be to save them in the n8n and combine them with the bash command cat header.csv body.csv > combined.csv. Example attached. Example files are stored in the first node as a base64 string for observability (use the copy button under the workflow to copy it).

1 Like

@barn4k Thanks for solution its partially working for me. there are some simple complication i might need to solve. except that its working good.

@barn4k @Jon just a little update. my problem is solved. thankyou for helping


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