I want to keep a datas during a loop and extract all the datas


In my workflow, I extract a list of datas which I transform into a JSON. But I have to do a loop to extract all the datas because I have to exploit the datas one by one.
After, I want to keep the transformed JSON to put all of them in a CSV (otherwise n8n returns a CSV by JSON), but I don’t know how to do it.
My workflow looks like this :

Could you help me please ?


You are using the old flow of the split in batches, if you use the newer version of n8n, it makes this very simple, as you won’t need that If check at the end. Are you using the latest version of n8n? If so, your flow should look more like this. Copy this to your instance and check out the 3 nodes I’ve added data to, “set final output for loop”, “Create Spreadsheet Blob” and write “spreadsheet blob to a file”.

The Set Final Output for loop is important as you will map the individual rows for the spreadsheet here in the loop, and the the done branch of the loop will output all the spreadsheet rows ready to be written to binary blob.

If you want to save the file locally to your server, use the write spreadsheet blob to a file. If you wish to do it remotely, remove that node and replace with the spreadsheet service of your choice.


Hi @djangelic, thank you for your answer. Actually I am not using the latest version of n8n, you’re right.
The node “Set” in my first post was intented to Set the final output for the loop but I don’t know how to build this final output, like, what do I have to write in the value to keep all the datas ?

If you use my workflow, the Set Final Output For Loop would be the rows of the spreadsheet defined as strings with the name being the column and the property value being the value of the spreadsheet cell. You would keep the columns static, but would use the expression editor to map your loop values to that property, so at the end of the loop you can write it to your spreadsheet file.

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