Add export_schools script
This commit is contained in:
parent
a51ff9a407
commit
dded12b70f
4 changed files with 37 additions and 0 deletions
1
scripts/export_schools/.gitignore
vendored
Normal file
1
scripts/export_schools/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.csv
|
BIN
scripts/export_schools/export_schools
Executable file
BIN
scripts/export_schools/export_schools
Executable file
Binary file not shown.
36
scripts/export_schools/main.go
Normal file
36
scripts/export_schools/main.go
Normal 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", "schools.csv", "Output filename")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
client, err := client.Dial(flag.Arg(0), *username, *password)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
schools := make([]*orm.School, 0)
|
||||
err = client.ReadAll(&schools)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f, err := os.Create(*output)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
gocsv.MarshalFile(schools, f)
|
||||
}
|
BIN
scripts/export_schools/scuole.xlsx
Normal file
BIN
scripts/export_schools/scuole.xlsx
Normal file
Binary file not shown.
Loading…
Reference in a new issue