Skip to content

Instantly share code, notes, and snippets.

@PierreZ
Created January 27, 2017 09:13
Show Gist options
  • Save PierreZ/22fd7a349e96710c13cb6f6b91883616 to your computer and use it in GitHub Desktop.
Save PierreZ/22fd7a349e96710c13cb6f6b91883616 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"encoding/base64"
"encoding/csv"
"fmt"
"io/ioutil"
"log"
"strings"
)
func main() {
body, err := ioutil.ReadFile("/home/pierre/Downloads/badges.csv")
r := csv.NewReader(bytes.NewReader(body))
warpscript := "{ "
records, err := r.ReadAll()
if err != nil {
log.Fatal(err)
}
for i, line := range records {
if i == 0 {
continue
}
//fmt.Println(i, line)
if len(line[5]) != 0 {
warpscript = warpscript + ` '` + base64.StdEncoding.EncodeToString([]byte(line[4])) + `' '` + strings.Replace(line[1]+" "+line[0], "'", "", -1) + `'`
}
}
warpscript = warpscript + ` } 'users' STORE`
fmt.Println(warpscript)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment