-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Milestone
Description
Current Functionality
structure
content/
└── posts/
└── post-1/
├── data.csv
└── index.md
content/posts/post-1/data.csv
"field_1";"field_2"
"foo";"bar"
"wibble";"wubble"
template
{{ $resource := .Resources.Get "data.csv" }}
{{ $data := transform.Unmarshal (dict "delimiter" ";") $resource }}
resulting data structure
[
[
"field_1",
"field_2"
],
[
"foo",
"bar"
],
[
"wibble",
"wubble"
]
]Desired Functionality
template
{{ $resource := .Resources.Get "data.csv" }}
{{ $data := transform.Unmarshal (dict "delimiter" ";" "toMap" true) $resource }}
resulting data structure
[
{
"field_1": "foo",
"field_2": "bar"
},
{
"field_1": "wibble",
"field_2": "wubble"
}
]Details
- The default value for
toMapshould befalse - This assumes the CSV file has a header row
- Related to Add support for *.tsv and *.csv files inside /data #8853