convert_u_vertex.py
1.13 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
import csv, sqlite3
con = sqlite3.connect("database2.db")
cur = con.cursor()
suffix = ["LN","LS","R","LE"]
fin = open("i.csv", "rt")
for line in fin:
number = int(line)
if(number >= 4000 and number <= 4057):
ins = "'" + line
ins = ins.replace('\n', '')
ins = ins + "_"
if(number >= 4000 and number < 4022):
ins = ins + suffix[0] + "'"
elif(number >= 4022 and number < 4027):
ins = ins + suffix[1] + "'"
elif(number >= 4027 and number < 4046):
ins = ins + suffix[2] + "'"
elif(number >= 4046 and number < 4057):
ins = ins + suffix[3] + "'"
else:
ins = ins + suffix[1] + "'"
cur.execute("SELECT internal FROM ug_ids WHERE external LIKE "+ins+";");
ugid = cur.fetchall()
print("% s" % ugid[0] + ",")
elif '_' in line:
ins = "'" + line
ins = ins.replace('\n', '\'')
cur.execute("SELECT internal FROM ug_ids WHERE external LIKE "+ins+";");
ugid = cur.fetchall()
print("% s" % ugid[0] + ",")
elif '-1' in line:
print("-1,")
else:
cur.execute("SELECT internal FROM ug_ids WHERE external = "+line+";")
ugid = cur.fetchall()
print("% s" % ugid[0] + ",")
con.commit()
con.close()
fin.close()