Add script for export participants

This commit is contained in:
Andrea Fazzi 2020-02-05 12:39:51 +01:00
parent d28507fc30
commit 72a31cd45d
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1 @@
*.csv

View file

@ -0,0 +1,36 @@
package main
import (
"flag"
"os"
"git.andreafazzi.eu/andrea/oef/client"
"git.andreafazzi.eu/andrea/oef/orm"
"github.com/gocarina/gocsv"
)
func main() {
username := flag.String("username", "admin", "Username")
password := flag.String("password", "admin", "Password")
output := flag.String("output", "participants.csv", "Output filename")
flag.Parse()
client, err := client.Dial(flag.Arg(0), *username, *password)
if err != nil {
panic(err)
}
participants := make([]*orm.Participant, 0)
err = client.ReadAll(&participants)
if err != nil {
panic(err)
}
f, err := os.Create(*output)
if err != nil {
panic(err)
}
defer f.Close()
gocsv.MarshalFile(participants, f)
}