-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_putThemBack.py
More file actions
66 lines (48 loc) · 1.42 KB
/
test_putThemBack.py
File metadata and controls
66 lines (48 loc) · 1.42 KB
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
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 15 17:30:28 2016
@author: yiz613
"""
import re
import sqlite3
import os
import random
import math
import pickle
import unPickle
conn = sqlite3.connect(r'matchTest.sqlite')
cur = conn.cursor()
#print ('Generating SQL file...')
cur.executescript('''
DROP TABLE IF EXISTS drugNameTable;
CREATE TABLE drugNameTable ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
drug_Name INTEGER NOT NULL);
''')
def afunc(inputDataFile):
def load(filename):
with open(filename, "rb") as f:
while True:
try:
yield pickle.load(f)
except EOFError:
break
items = load(inputDataFile)
unpickleList=list(items)
targetResult = list()
for eachSample in unpickleList:
targetResult.append(int(eachSample[0]))
return targetResult
Druglist =list()
DrugList = afunc("encoded_train_pickle")
for drug in DrugList:
cur.execute('''INSERT INTO drugNameTable (drug_Name) VALUES ( ? )''', (drug, ) )
conn.commit()
DrugList = afunc("encoded_valid_pickle")
for drug in DrugList:
cur.execute('''INSERT INTO drugNameTable (drug_Name) VALUES ( ? )''', (drug, ) )
conn.commit()
DrugList = afunc("encoded_test_pickle")
for drug in DrugList:
cur.execute('''INSERT INTO drugNameTable (drug_Name) VALUES ( ? )''', (drug, ) )
conn.commit()
cur.close()