I know there will be someone with more knowledge on how to do this (efficiently)…
Is it possible to have a key in front matter and look up a CSV to return the row of data referenced by that key and making each snippet of data available?
so far I can load the CSV
{{ $CSV := getCSV "," "data/abc.csv" }}
output the whole range that is on the CSV…
{{ range $CSV }}<br> {{ . }} {{ end }}
and find a couple of random rows and output them…
{{ $CSV | shuffle | first 2 }}
however - what i hope to do… with front matter like this example…
+++
title = “some random page title”
id = “111”
+++
And CSV like this example…
id, description, color, number, cat, image
110, blue pearl, blue, 10, pearls, bpearl.jpg
111, green pearl, green, 12, pearls, gpearl.jpg
112, orange peel, orange, 19, fruit, opeel.jpg
→ lookup the csv with something like…
{{ range $r := $CSV where "id" == .Params.id }} (I know this is not correct)
to find the id the same as the one in the front matter, load that row, make available each aspect of data, and use the data on my page…
<div class = "{{ $r.cat }}">
<span> {{ $r.id }}</span>
<span> {{ $r.description }}</span>
<span> {{ $r.color }}</span>
<span> {{ $r.number }}</span>
</div>
<img src = "{{ $r.image }}>
I dont know enough and have spent a lot of time on docs / here / Go / stack exchange and nothing that works to date.
this is the closest I have found - Range over getCSV array not iterating - #3 by O_O but no joy using it
Thanks in advance…