Csv file to json

Hi n8n community,

I am a new user, trying to migrate over from Integromat. Not a highly technical user, so I’m hoping to learn :slight_smile:

I run an http call and as a result I’m receiving is a csv file. I eventually need to store this data in a database. I think I would first need to transform the data into json format for further processing.

Is this something that I have to do with javascript, or is there an ‘off the shelve’ solution?

This is the result I get from the http call:

office_id,office_name 1,“OfficeName 1” 5,“OfficeName 2” 6,“OfficeName 3” 7,“OfficeName 4”

The file should be in this format:
[
{
“office_id”: 1,
“office_name”: “OfficeName 1”
},
{
“office_id”: 5,
“office_name”: “OfficeName 2”
},
{
“office_id”: 6,
“office_name”: “OfficeName 3”
},
{
“office_id”: 7,
“office_name”: “OfficeName 4”
}
]

Would I need to do this using javascript?

Any help is greatly appreciated!

Thanks!

Hi @maartend, welcome to the community!

Assuming it’s a valid CSV file you could in a first step download your data as a file using the HTTP Request:

In a second step you can then use the Spreadsheet File node to read your CSV file which should give you the JSON data structure you’re looking for:

This is how it looks as a complete workflow:

Is this what you have in mind?

1 Like

Wow! This worked like a charm. Thanks for your help! :+1:

1 Like

Sweet, thanks so much for confirming!