Correct way of creating spreadsheet data from json?

Hi all.
I’m facing an issue with converting json to spreadsheet data (any format).

[n8n v0.118.1]

Here's an example workflow:

The Actual output:

0.a 0.b 0.c 1.a 1.b 1.c 2.a 2.b 2.c 3.a 3.b 3.c 4.a 4.b 4.c 5.a 5.b 5.c 6.a 6.b 6.c 7.a 7.b 7.c 8.a 8.b 8.c 9.a 9.b 9.c
0 0 0 1 2 1 2 4 2 3 6 3 4 8 4 5 10 5 6 12 6 7 14 7 8 16 8 9 18 9

The Expected output:

a b c
0 0 0
1 2 1
2 4 2
3 6 3
4 8 4
5 10 5
6 12 6
7 14 7
8 16 8
9 18 9

Would like to know if i’m:

  • expecting the wrong output/there’s something wrong with my workflow, or
  • there’s a bug with the node
    ?

Hi @shrey-42 , your logic is correct, only a small detail missing;
your Function node return one single item which contain all the lines, while you need to return multiple items (where each item contain one line)

I added a small modification to your code in the Function node and that should solve it, please give a try and let me know if that helps;

Also, i suggest checking this livestream, where Ivan and Tanay explained in great details how to deal with the data in n8n.
Function node code;

const result = [];
for(let i=0; i<10; i++){
  result.push({
    json:{
      a: i,
      b: i*2,
      c: String(i)
    }
  });
}
return result;

workflow json

2 Likes

Hi @dali , thanks for your response.

Didn’t realise that the table rows needed to be sent as individual items.