-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepo.go
More file actions
35 lines (26 loc) · 686 Bytes
/
Repo.go
File metadata and controls
35 lines (26 loc) · 686 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
package main
import (
"io/ioutil"
"strings"
)
var flightRoutes FlightRoutes
func check(e error) {
if e != nil {
panic(e)
}
}
func init() {
tableName := "routes"
tableFields := []string{"Airline", "AirlineId", "SourceAirportCode", "SourceAirportId", "DestAirportCode", "DestAirportId", "Codeshare", "Stops", "Equipment"}
mysql := GetServiceURI("mysql")
CreateTable(mysql, "picasso", "picasso", "picasso", tableName)
dat, err := ioutil.ReadFile("routes.csv")
check(err)
ports := strings.Split(string(dat), "\n")
for _, port := range ports {
if strings.Contains(port, ",") {
tokens := strings.Split(port, ",")
AddRow(tableName, tableFields, tokens)
}
}
}