Skip to content

Add "toMap" to transform.Unmarshal CSV options #8859

@jmooring

Description

@jmooring

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions