$parseCsv
$parseCsv(csvText) -> array<object>Source: FUME
Documentation
Parses raw CSV text and returns an array of row objects keyed by the header row.
This is the same converter the engine uses before evaluating CSV requests, but it is also useful mid-mapping when a field contains embedded CSV text that you need to parse on demand. Values remain strings, empty cells remain empty strings, empty input returns [], and malformed CSV also returns []. If a row has more fields than the header row, the extra values are exposed as generated keys such as field4 and field5.
Examples
Parse a CSV document into row objects
Input
This example uses the canonical encounters CSV file as the raw input string passed to the function.
Example input
CSV
encounterId,patientId,status,class,type,reason,facility,practitionerId,start,end
enc-1001,pat-0001,finished,outpatient,primary-care,routine follow-up,ExampleCare Clinic,prac-4001,2026-02-14T09:30:00Z,2026-02-14T10:05:00Z
enc-1002,pat-0001,finished,outpatient,imaging,headache evaluation,ExampleCare Imaging,prac-4002,2026-03-01T15:10:00Z,2026-03-01T15:45:00Z
enc-1003,pat-0001,in-progress,virtual,care-coordination,medication questions,ExampleCare Clinic,prac-4003,2026-03-10T11:20:00Z,
enc-1004,pat-0001,planned,outpatient,lab,fasting labs,ExampleCare Clinic,prac-4001,2026-03-20T08:00:00Z,
Expression
$parseCsv($)
The result below is abbreviated to keep the example readable.
Result
[
{
"encounterId": "enc-1001",
"patientId": "pat-0001",
"status": "finished",
"class": "outpatient",
"type": "primary-care",
"reason": "routine follow-up",
"facility": "ExampleCare Clinic",
"practitionerId": "prac-4001",
"start": "2026-02-14T09:30:00Z",
"end": "2026-02-14T10:05:00Z"
},
{
"encounterId": "enc-1002",
"patientId": "pat-0001",
"status": "finished",
"class": "outpatient",
"type": "imaging",
"reason": "headache evaluation",
"facility": "ExampleCare Imaging",
"practitionerId": "prac-4002",
"start": "2026-03-01T15:10:00Z",
"end": "2026-03-01T15:45:00Z"
}
]