initialize_cond.py
1.83 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
67
68
69
70
71
72
import csv, re, sqlite3
con = sqlite3.connect("database_modfire.db")
cur = con.cursor()
cur2 = con.cursor()
cur3 = con.cursor()
cur4 = con.cursor()
cur5 = con.cursor()
f = open("wood_total_init.txt", "w+")
f2 = open("soilloss_total_init.txt", "w+")
f3 = open("perc_r0_total_init.txt", "w+")
f4 = open("perc_r5_total_init.txt", "w+")
f5 = open("perc_r10_total_init.txt", "w+")
for i in range(0, 1406):
cur.execute("SELECT Presc, wood FROM wood_rewards where ug like "+str(i))
cur2.execute("SELECT Presc, Soilloss FROM soilloss where ug like "+str(i))
cur3.execute("SELECT Presc, perc_r0_total FROM perc_r0 where ug like "+str(i))
cur4.execute("SELECT Presc, perc_r5_total FROM perc_r5 where ug like "+str(i))
cur5.execute("SELECT Presc, perc_r10_total FROM perc_r10 where ug like "+str(i))
results = cur.fetchall()
results2 = cur2.fetchall()
results3 = cur3.fetchall()
results4 = cur4.fetchall()
results5 = cur5.fetchall()
toWrite = ''
toWrite2 = ''
toWrite3 = ''
toWrite4 = ''
toWrite5 = ''
currentP = results[0][0]
for j in range(0, len(results)):
if(results[j][0] == currentP):
toWrite += str(results[j][1])
toWrite2 += str(results2[j][1])
toWrite3 += str(results3[j][1])
toWrite4 += str(results4[j][1])
toWrite5 += str(results5[j][1])
else:
toWrite = toWrite[:-1]+","
toWrite2 = toWrite2[:-1]+","
toWrite3 = toWrite3[:-1]+","
toWrite4 = toWrite4[:-1]+","
toWrite5 = toWrite5[:-1]+","
currentP = results[j][0]
toWrite += str(results[j][1])
toWrite2 += str(results2[j][1])
toWrite3 += str(results3[j][1])
toWrite4 += str(results4[j][1])
toWrite5 += str(results5[j][1])
f.write(toWrite + "\n")
toWrite = ''
f2.write(toWrite2 + "\n")
toWrite2 = ''
f3.write(toWrite3 + "\n")
toWrite3 = ''
f4.write(toWrite4 + "\n")
toWrite4 = ''
f5.write(toWrite5 + "\n")
toWrite5 = ''