package util import ( "fmt" "os" "strings" ) // TODO: https://gist.github.com/andrea3bianchi/16d42a277db7b3de43b2a316b7894dbd func PrintQuotedCsv(data [][]string, filename string, delimiter string) error { f, err := os.Create(filename) defer f.Close() if err != nil { return err } for _, row := range data { sep := "" for _, cell := range row { _, err = f.WriteString(fmt.Sprintf(`%s"%s"`, sep, strings.Replace(cell, `"`, `""`, -1))) if err != nil { return err } sep = delimiter } _, err = f.WriteString("\n") if err != nil { return err } } return nil }