makeSolFile.py
860 Bytes
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
import csv, re, sqlite3
fy= open("Maps/MapInputFile.txt", "w+")
con = sqlite3.connect("database_modfire.db")
cur = con.cursor()
print('Enter name of file in results folder (single solution): ')
print('Example: Paredes-SingleSolution.csv')
x = input()
Filemame = "Results/"+str(x)
f=open(Filemame,"r")
lines=f.readlines()
result=[]
#0-Year,1-Spec,2-Thin,3-Harv
for line in lines:
MU = line.split(',')[0]
Pr = line.split(',')[1]
cur.execute("SELECT Year, Species, V_thin, V_harv FROM action_external where Id = "+str(MU)+" and Presc = "+str(Pr)+" and (V_thin or V_harv) > 0.0")
result = cur.fetchall()
for i in range(0, len(result)):
year = result[i][0]
act = ''
if(int(result[i][2]) > 0):
act = 't'
else:
act = 'h'
toWrite = str(MU)+","+str(year)+","+str(result[i][1])+"-"+act+"\n"
fy.write(toWrite)
fy.close()