Something went wrong. Try again.
moderation music collection code, output, history etc.
Something went wrong. Try again.
moderation rqlite.go
1.1 kB · 71 lines
Go
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172package main
import ( "encoding/csv" "fmt" "log" "os" "strings")
func main() {
var output string
// open file, count rows, reset seek filer, err := os.Open("moderation.csv") if err != nil { fmt.Println("Error:", err) return } defer filer.Close()
csvReader := csv.NewReader(filer) all, _ := csvReader.ReadAll() log.Println(len(all)) var celllength int
for i, line := range all { // log.Println(i) if i == 0 { celllength = len(line) - 1 log.Println(celllength) continue }
output += "("
for x, cell := range line { // log.Println(cell) // replace double quotes with escaped version for sqlite in Title and Related columns if x == 1 || x == 13 { output += "'" + strings.Replace(cell, "\"", "\\\"", -1) + "'" } else { output += "'" + cell + "'" } if x == celllength { continue } else { output += "," } }
output += ")"
if i == len(all)-1 { continue } else { output += "\n" }
}
// persist to html filef, err := os.Create("moderation.rqlite") // For write access. if err != nil { log.Fatal(err) } filef.WriteString(output) filef.Close()
}