openlca-python-tutorial
openlca-python-tutorial copied to clipboard
Update single flows in process
Hi, I am trying to update a single flow inside a process, e.g. to adjust the amount or even delete it from the process. The way I am doing it right now, is to create a new exchange list and update the whole process. That way, all unchanged flows have to be part of the new exchange list again, though. Is there a way to only change certain flows within a process? Something like
process = client.get(olca.Process, 'fb0d68e9-9a14-431b-ac34-1f9a14c18de8')
for "flow" in process:
if flow.id = "dc50a884-b2f5-4c95-9912-07b8dfb2d497":
flow.amount = 5
client.update(process)
Thanks for any hints!
Something like this should work:
import olca
client = olca.Client()
process = client.get(olca.Process, '0b62c9f4-5d2e-42fb-a32b-310b3f493e5f')
for e in process.exchanges:
if e.flow.id == '8772a1a2-9a23-c6bf-8a87-4800c60f4e87':
e.amount = 5
client.update(process)
Great, thank you very much, it worked! :)