Blame view

MODFIRE-Prototype/res/initialize_graph.py 783 Bytes
16f90fbc   Eduardo Eloy   database and impl...
1
2
import csv, re, sqlite3

a4f37eed   Eduardo Eloy   initizalyzers for...
3
con = sqlite3.connect("database_modfire.db")
16f90fbc   Eduardo Eloy   database and impl...
4
cur = con.cursor()
a4f37eed   Eduardo Eloy   initizalyzers for...
5
6
f = open("adj_init.txt", "w+")
f2 = open("border_init.txt", "w+")
16f90fbc   Eduardo Eloy   database and impl...
7
8
9
10

toWrite = ''


a4f37eed   Eduardo Eloy   initizalyzers for...
11
12
for i in range(0, 1406):
	cur.execute("Select ug2 from adj_int where ug1 like "+str(i))
16f90fbc   Eduardo Eloy   database and impl...
13
14
	result = cur.fetchall()
	if(result == []):
a4f37eed   Eduardo Eloy   initizalyzers for...
15
		toWrite = "-1\n"
16f90fbc   Eduardo Eloy   database and impl...
16
17
18
19
20
	else:
		for j in range(0, len(result)):	
			toWrite += str(result[j]).replace(')','').replace('(','')
		toWrite = toWrite[:-1]+"\n"
	f.write(toWrite)
a4f37eed   Eduardo Eloy   initizalyzers for...
21
	toWrite = ''
16f90fbc   Eduardo Eloy   database and impl...
22
	
a4f37eed   Eduardo Eloy   initizalyzers for...
23
	cur.execute("Select front from adj_int where ug1 like "+str(i))
16f90fbc   Eduardo Eloy   database and impl...
24
	result = cur.fetchall()
a4f37eed   Eduardo Eloy   initizalyzers for...
25
26
27
28
29
30
	if(result == []):
		toWrite = "-1\n"
	else:
		for j in range(0, len(result)):	
			toWrite += str(result[j]).replace(')','').replace('(','')
		toWrite = toWrite[:-1]+"\n"
16f90fbc   Eduardo Eloy   database and impl...
31
32
	f2.write(toWrite)
	toWrite = ''