+1 vote
848 views

Hello, 

I have a list of 70 parameters (in excel) that I would like to add as global parameters in my database and I would like to add it using Python code. I followed some steps provided in GitHub and on the Open LCA 1.9 manual but it does not seem to work. Please kindly visit my enquiry at GitHub: Github Inquiry. Thank you very much for your kind attention.

Best Regards,

Astu 

in openLCA by (480 points)

1 Answer

+1 vote
by (14.0k points)
selected by
 
Best answer

As you are on macOS `C:/Users...` is not a valid path to a folder on your system (it is a DOS path that works on Windows). This is the reason you get the first error.

Also, you do not attach global parameters to a process. Because when you delete that process also these parameters are deleted. You can use the `ParameterDao` to create stand-alone global parameters like this:

from org.openlca.core.model import Parameter, ParameterScope
from org.openlca.core.database import ParameterDao
 
# create a global input paramater
param = Parameter()
param.name = "global_p"
param.scope = ParameterScope.GLOBAL
param.isInputParameter = True
param.value = 5
 
# create the paramater DAO and insert the paramater in
# the database
dao = ParameterDao(db)
dao.insert(param)
by (480 points)
Thank you so much for your quick answer. Yes I managed to add global parameter now.
Indeed, I realised that the parameters I attached to a process were gone when the process was deleted.
...