-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatchCalc.py
More file actions
39 lines (32 loc) · 1.09 KB
/
batchCalc.py
File metadata and controls
39 lines (32 loc) · 1.09 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
import csv
filePath = 'C:/Users/nstoddar/Data/template.csv'
def findId(folder, process, location):
id = []
def checkProc(p):
if p.getCategory().name == folder and p.name == process and p.location.name==location:
id.append(p.id)
return id
olca.eachProcess(checkProc)
if len(id)==1:
return id[0]
elif len(id)>1:
log.error("Whoops I found more than one {}{} to update in {}", process, location, folder)
return
else:
log.error("Uh oh! I couldn't find {}{} anywhere in {}. Check your spelling and try again!",process,location,folder)
return
def updateProcess(id,flow,amount):
pro = olca.getProcess(id)
exs = pro.getExchanges()
for ex in exs:
if ex.flow.name == flow:
ex.amountValue = float(amount)
olca.updateProcess(pro)
log.info("{} has been updated",pro.name)
return
with open(filePath, 'rb') as csvfile:
linereader = csv.reader(csvfile, delimiter=',',quotechar='"')
next(linereader)
for row in linereader:
id = findId(row[0],row[1],row[4])
updateProcess(id,row[2],row[3])