Standard parser csvutils.parse(data)

Use this function for standard CSV data where the first line contains headers and the fields are separated by commas. This function returns an array of maps. Each item in the array represents a row and contains a key-value map where the key is the column header and the value is the cell data.

Syntax:

var result = csvutils.parse(data); // data is a string

Example

Input data:

ID,Name,Role
101,Alice,Admin
102,Bob,User

Script:

var csvString = "ID,Name,Role\n101,Alice,Admin\n102,Bob,User";  
var records = csvutils.parse(csvString);  
// Accessing data  
var firstUser = records[0];  
processlog.info("Name: " + firstUser["Name"]); // Output: Name: Alice  
processlog.info("Role: " + firstUser["Role"]); // Output: Role: Admin