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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
package main
import (
"fmt"
"airlines/pkg/adapters/csv"
"airlines/pkg/adapters/json"
"airlines/pkg/adapters/xlsx"
"airlines/pkg/adapters/xml"
"airlines/pkg/adapters/yaml"
"airlines/pkg/localstore"
"github.com/joho/godotenv"
)
func main() {
// run with MAKE only
err := godotenv.Load("../../.env")
if err != nil {
fmt.Println(err)
}
//fmt.Sprintf("postgres://%s:%s@%s:%s/%s", os.Getenv("DB_USER"), os.Getenv("DB_PASSWORD"), os.Getenv("DB_HOST"), os.Getenv("DB_PORT"), os.Getenv("DB_NAME")))
// store, err := store.NewStore("user=postgres dbname=airlines host=/home/alex/.pgsocket sslmode=disable")
store := localstore.NewLocalStore()
fmt.Println("store created")
func() {
root, err := json.UnmarshalJsonRoot("/home/alex/ds-data/FrequentFlyerForum-Profiles.json")
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled json")
root.DumpToDb(store)
fmt.Println("\ndumped json")
}()
func() {
// xlsx
tickets, err := xlsx.UnmarshallXlsxFiles("/home/alex/ds-data/YourBoardingPassDotAero/")
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled xlsx")
xlsx.DumpToDb(store, tickets)
fmt.Println("\ndumped xlsx to db")
}()
func() {
xmldata, err := xml.UnmarshalXml("/home/alex/ds-data/PointzAggregator-AirlinesData.xml")
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled xml")
xmldata.DumpToDb(store)
fmt.Println("\ndumped xml to db")
}()
func() {
yamlData, err := yaml.UnmarshallYaml("/home/alex/ds-data/SkyTeam-Exchange.yaml")
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled yaml")
yamlData.DumpToDb(store)
fmt.Println("\ndumped yaml to db")
}()
func() {
csvData, err := csv.UnmarshallCsv("/home/alex/ds-data/csv.csv", false)
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled csv1")
csvData.DumpToDb(store)
fmt.Println("\ndumped yaml to csv1")
}()
// fuck it
func() {
csvData2, err := csv.UnmarshallCsv("/home/alex/ds-data/tab.csv", true)
if err != nil {
panic(err)
}
fmt.Println("\nunmarshalled csv2")
csvData2.DumpToDb(store)
fmt.Println("\ndumped yaml to csv2")
}()
fmt.Println(store.ExportAllCSVs("/tmp/ds"))
}
|