-
Notifications
You must be signed in to change notification settings - Fork 28
/
migrate_txt_files.py
129 lines (77 loc) · 3.42 KB
/
migrate_txt_files.py
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import sqlite3 as sq
import initdb
initdb.initdb()
conn = sq.connect('bot.db')
c = conn.cursor()
fs = open('resources/icd.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Diagnoosi(diagnoosi) values(?)", (line,))
fs.close()
fs = open('resources/icd_fxx.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO DiagnoosiFxx(diagnoosi_fxx) values(?)", (line,))
fs.close()
fs = open('resources/viisaudet.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Viisaus(viisaus) values(?)", (line,))
fs.close()
fs = open('resources/kaloja.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Kalat(kala) values(?)", (line,))
fs.close()
fs = open('resources/maidot.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Maito(maito) values(?)", (line,))
fs.close()
fs = open('resources/nimet.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Nimi(nimi) values(?)", (line,))
fs.close()
fs = open('resources/vihanneet.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Vihannes(nimi) values(?)", (line,))
fs.close()
fs = open('resources/kulkuneuvot.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Kulkuneuvo(nimi) values(?)", (line,))
fs.close()
fs = open('resources/planetoidit.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Planetoidi(nimi) values(?)", (line,))
fs.close()
fs = open('resources/lintuslangi.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Linnut(nimi) values(?)", (line,))
fs.close()
fs = open('resources/sotilasarvot.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Arvonimet(nimi) values(?)", (line,))
fs.close()
fs = open('resources/sotilasnimet.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Sotilasnimet(nimi) values(?)", (line,))
fs.close()
fs = open('resources/kasvinimet.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Kasvinimet(nimi) values(?)", (line,))
fs.close()
fs = open('resources/ennustus.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Ennustus(rivi) values(?)", (line,))
fs.close()
fs = open('resources/nakutukset.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Nakutukset(nakutus) values(?)", (line,))
fs.close()
fs = open('resources/selitykset.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Korttiselitykset(kortti, selitys, rev) values(?,?,?)", (line.split("@@@")[0], line.split("@@@")[1], line.split("@@@")[2]))
fs.close()
fs = open('resources/joulukalenteri.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Joulukalenteri(linkki) values(?)", (line,))
fs.close()
fs = open('resources/torit.txt', 'r', encoding='utf-8')
for line in fs.read().splitlines():
c.execute("INSERT OR IGNORE INTO Torit(tori) values(?)", (line,))
conn.commit()