hi there,
i think this is what exactly what i need. however, my GroupBy Data is in the row of a .csv file. I tried to adjust your code to make it work, but I keep getting errors, (I am not very advanced, not sure what I am doing wrong). I entered this in index.html
{{ define "main" }}
{{ $url := "web.csv" }}
{{ $sep := "," }}
{{ /* $url */}}
{{ $tag := (index $r 14) }}
{{ range $i, $r := getCSV $sep $url }}
{{ $tag = $tag | append (index $r 14) }}
{{ end }}
{{ $tag = uniq $tag | sort }}
<h2>Directory of Libraries in the United States</h2>
<ul>
{{ range $tag }}
{{ $list := . }}
<li>{{ . }}
{{ range where $i, $r := getCSV $sep $url (index $r 14) $list }}
<ul>
<li>{{ (index $r 14)}}
<ul>
</li>
</ul>
{{ end }}
</li>
{{ end }}
</ul>
Server complains about $r
parse failed undefined variable “$r”
If you have any idea, where I have gone wrong, I’d be super thankful ^^
You are using $r in the same range definition where you define it, so it has no value, hence undefined.
Also, I suspect you have that whole line wrong syntax-wise. I don’t think you can use where like that with the assignment after it and … yea that whole line looks very wrong.
I suggest getting more familiar with how where 12 works, how range works, and you probably need another set of parenthesis around the getCSV call in that line.