Range over getCSV array not iterating

Thanks for the quick reply @Jonathan_Griffin , your code suggestion gave me the idea to do some testing and see what the {{ . }} dot contained at different points. I found that it was iterating correctly, I just wasn’t accessing the data correctly.

I first tried replacing the (index $r $i) function with the . alone as {{$c := split . ","}} however it was throwing the following error:

error calling split: unable to cast []string
{"Name,(555)123-4567,email1@domain.com"} 
of type []string to string

So in order to access what was in . from split I needed to access the string within []string so i used (index . 0) to get it in the right format for split to separate by commas. The code I got working is below:

{{range $i, $r := getCSV "\r" "/rolodex.csv"}}
{{$c := split (index . 0) ","}}
<dt>{{index $c 0}}</dt>
<dd>{{index $c 1}}<dd>
<dd>{{index $c 2}}<dd>
{{end}}

This code breaks up the CSV file into rows by each carriage return, "\r" and columns from each comma "," allowing you to iterate through all the rows and place specific column data in different parts of the range contents using index. This makes it easy to use data from a csv that is grouped by line with different types of values in different columns, and also be able to have multiple tables in a single csv file (each line a table with the first column {{index $c 0}} as the table header). I hope this helps someone else looking for an answer to this problem.


Update:
further explanation here: [Solved] CSV data key lookup - #3 by O_O