Exporting to CSV has all data in one row, not in columns

When the spreadsheet file is written, it’s putting all the data in row, and not in a normal row / column output like the array shows in the HTML node.

Please share your workflow

Share the output returned by the last node

I should clarify, this is what the output looks like:

Row 1 : Title.0 Title.1 etc etc url.0 url.1 url.2 etc etc
Row 2: title for Title.0 Title for Title1 etc etc url for url21 url for url.2 etc etc

So it is not doing what is expected in a spreadsheet which is:

Column 1 - Column 2
Row 1 Title.0 url.0
Row 1 Title.1 url.1

Information on your n8n setup

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

Hi @privateuserguy

Can you share some example data that you receive from your HTTP Request Node? I cannot access the provided URL :frowning: But would like to know the data structure that you are working with.


No problem, it’s not a private issue really and the company that’s asked for it has said it’s fine:

Thank You @privateuserguy! Now I can see what’s going on :slight_smile:

Your data structure is currently like this (one object with all titles and urls together as array values)

"Title": ["Title1", "Title2"],
"url": ["url1", "url2"]

But for the CSV conversion you need the data to be separated into individual objects:

"Title":  "Title1",
"url":  "url1"
"Title": "Title2",
"url": "url2"

You can achieve this by placing a Code Node between your HTML1 Node and Sort Node and do some data transformation there:

const items = $input.all()

return items[0].json.Title.map((item, index) => {
  return {
    json: {
      'Title': item,
      'url': `${items[0].json.url[index]}`

Here’s the workflow:

Hope this helps :blush: Let us know how you get on! :palm_tree:


PS. You could also use the Split Out Node to achieve the same thing :wink:

Absolutely beautiful! Thank you so much for your help. I very much appreciate it. I chose the code method, so I can study it and try and learn more from it.

I’ll do some study on .map() :slight_smile:

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