from_csv
Parses a CSV string into a list of rows, so a serialized table (a report export, a spreadsheet dump) becomes data that later template steps can filter and pluck.
The first record is the header row, and each remaining row becomes one map keyed by header. Cells stay strings, so coerce them downstream with other modifiers if you need numbers. Fully blank lines are skipped, and a row with fewer cells than the header pads the missing columns with an empty string.
stringno arguments[]map[string]anyParses a CSV string into a list of rows keyed by the header, treating the first record as the header row.
Given
{"body": "name,age\nAlice,30\nBob,25"}Template
{{ body | from_csv }}Result
[
{
"age": "30",
"name": "Alice"
},
{
"age": "25",
"name": "Bob"
}
]Shows that a CSV with only a header row and no data rows parses into an empty list.
Given
{"body": "name,age\n"}Template
{{ body | from_csv }}Result
[]Shows that a row with fewer cells than the header pads the missing columns with an empty string.
Given
{"body": "a,b,c\n1,2"}Template
{{ body | from_csv }}Result
[
{
"a": "1",
"b": "2",
"c": ""
}
]