ParseCSV
less than a minute
The ParseCSV converter parses a CSV row with headers into an array of fields.
Syntax: ParseCSV(value, headers)
- value: the bracket notation location or literal of a CSV row.
- headers: the bracket notation location or literal of the CSV headers.
Input
{
"_type": "log",
"timestamp": 1734493785759,
"body": "log message",
"resource": {...},
"attributes": {
"csv": "ABC123,user1,login,success",
"csv_headers": "Session_ID,User_ID,Event_Type,Event_Details"
}
}
Statement
set(attributes["csv_parsed"], ParseCSV(attributes["csv"], attributes["csv_headers"]))
Output
{
"_type": "log",
"timestamp": 1734493808937,
"body": "log message",
"resource": {...},
"attributes": {
"csv": "ABC123,user1,login,success",
"csv_headers": "Session_ID,User_ID,Event_Type,Event_Details",
"csv_parsed": {
"Event_Details": "success",
"Event_Type": "login",
"Session_ID": "ABC123",
"User_ID": "user1"
}
}
}
The CSV row was parsed using the headers as field names.