-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepo.go
More file actions
39 lines (29 loc) · 698 Bytes
/
Repo.go
File metadata and controls
39 lines (29 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"io/ioutil"
"strings"
)
var airlineCodes AirlineCodes
func check(e error) {
if e != nil {
panic(e)
}
}
func init() {
tableName := "airline"
tableFields := []string{"Id", "Name", "IATA", "ICAO", "CallSign", "Country", "Comments"}
mysql := GetServiceURI("mysql")
CreateTable(mysql, "picasso", "picasso", "picasso", tableName)
dat, err := ioutil.ReadFile("airline_codes.csv")
check(err)
lines := strings.Split(string(dat), "\n")
for _, line := range lines {
if strings.Contains(line, ",") {
tokens := strings.Split(line, ",")
if len(tokens[3]) == 0 {
continue
}
AddRow(tableName, tableFields, append(tokens[:2], tokens[3:]...))
}
}
}