Skip to main content

Transform CSV to JSON

Taking CSV data and converting it into JSON data using Frends.

T
Written by Tikriti Shabudin
Updated over 2 years ago

In this guide, we will create a short Process that reads CSV data and converts it into JSON data. We will use a sample dataset as an example of CSV data. The example CSV dataset can be found below:

1,Addie Henderson,19
2,Lilly Reeves,21
3,Rebecca Bradley,47
4,Joseph Bryan,46
5,Juan Gibson,58
6,Melvin Armstrong,52
7,Elsie Curtis,63
8,Mable Salazar,18
9,Mittie Parsons,18
10,Andrew Cooper,31

Steps for creating the Process

  1. Create a process and give it a name.

  2. Add a new Task Element and attach it to the Process Trigger.


  3. Within the new Task, select "Parse" from the "Select a Task" dropdown menu found in the "FRENDS.CSV" section.

  4. Insert the example CSV dataset into the "CSV" field within the Task. In the delimiter field, enter the delimiter used in the CSV data you are transforming. In the case of the example dataset, the delimiter is a comma.

  5. Click the "Add item" button in the "Column specifications" field. For each column of data, add an item to specify the contents of the column. In the case of the example dataset, you need three items as there are three columns.
    Within the "Name" field, enter the name that suits the data of the specific column. The dropdown menu named "Type" can be left as "String".
    The following pictures show how the "Column specifications" field should look for the example dataset. If you want, you can leave the whole "Column specifications" empty, but in that case, it is up to Frends to guess column names and data types, and because our data won't include headers, all column names would not have names in that case.

  6. Change the tab from "Input" to "Option". If your CSV dataset includes headers, then ensure that the "Contains header row" field is on. If the dataset does not include headers, such as the example dataset, ensure that the field is off.

  7. Attach a Return Element to the Task and within the "Expression" field of the Return, enter: #result[CSV Parse].Jtoken

When looking at the result and selecting "Show raw", the first few lines of the returned JSON data transformed from the sample CSV data should look similar to this:

Did this answer your question?