openlca-python-tutorial icon indicating copy to clipboard operation
openlca-python-tutorial copied to clipboard

Update single flows in process

Open dontoasty opened this issue 3 years ago • 2 comments

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!

dontoasty avatar Sep 21 '21 12:09 dontoasty

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)

msrocka avatar Sep 24 '21 08:09 msrocka

Great, thank you very much, it worked! :)

dontoasty avatar Sep 25 '21 09:09 dontoasty