package main import ( "bytes" "encoding/csv" "fmt" "html/template" "strings" ) var c = `Character,Speech The multitude,The messiah! Show us the messiah! Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away! The multitude,Who are you? Brians mother,I'm his mother; that's who! The multitude,Behold his mother! Behold his mother!` func main() { if h, err := csvToHtml(c); err != nil { fmt.Println(err) } else { fmt.Print(h) } } func csvToHtml(c string) (string, error) { data, err := csv.NewReader(bytes.NewBufferString(c)).ReadAll() if err != nil { return "", err } var b strings.Builder err = template.Must(template.New("").Parse(` {{range .}} {{range .}}{{end}} {{end}}
{{.}}
`)).Execute(&b, data) return b.String(), err }