首先,总的来说,我对 bw2 和 LCA 还很陌生,所以请理解。
我目前正在研究一种将生态发明活动的交换导出到 excel 表的工具。在 excel 表中,我想更改金额并添加新的或删除的交换。之后,我的计划是使用这个 excel 表作为 LCA 的数据库。
我有两个问题:
1)目前有一个带有活动及其交换的excel表准备加载到jupyter笔记本中。我使用了 maxkoslowski 的“Brightway2_Intro”的“excel_importer_example”结构。在我必须使用“.write_database()”之前它工作正常。不知何故,它不会工作。我收到一条对我毫无帮助的错误消息:
*InvalidExchange Traceback (most recent call last)
<ipython-input-149-0d0d7c5cd566> in <module>
----> 1 imp.write_database() #hier das Problem: Database wird nicht gespeichert, obwohl Datei in Zeile drüber gefunden wird
~\Miniconda3\envs\tomaten\lib\site-packages\bw2io\importers\excel.py in write_database(self, **kwargs)
257 """Same as base ``write_database`` method, but ``activate_parameters`` is True by default."""
258 kwargs['activate_parameters'] = kwargs.get('activate_parameters', True)
--> 259 super(ExcelImporter, self).write_database(**kwargs)
260
261 def get_activity(self, sn, ws):
~\Miniconda3\envs\tomaten\lib\site-packages\bw2io\importers\base_lci.py in write_database(self, data, delete_existing, backend, activate_parameters, **kwargs)
238
239 existing.update(data)
--> 240 db.write(existing)
241
242 if activate_parameters:
~\Miniconda3\envs\tomaten\lib\site-packages\wrapt\wrappers.py in __call__(self, *args, **kwargs)
604 return self._self_wrapper(wrapped, instance, args, kwargs)
605
--> 606 return self._self_wrapper(self.__wrapped__, self._self_instance,
607 args, kwargs)
608
~\Miniconda3\envs\tomaten\lib\site-packages\bw2data\project.py in writable_project(wrapped, instance, args, kwargs)
354 if projects.read_only:
355 raise ReadOnlyProject(READ_ONLY_PROJECT)
--> 356 return wrapped(*args, **kwargs)
~\Miniconda3\envs\tomaten\lib\site-packages\bw2data\backends\peewee\database.py in write(self, data, process)
258 if data:
259 try:
--> 260 self._efficient_write_many_data(data)
261 except:
262 # Purge all data from database, then reraise
~\Miniconda3\envs\tomaten\lib\site-packages\bw2data\backends\peewee\database.py in _efficient_write_many_data(self, data, indices)
202
203 for index, (key, ds) in enumerate(data.items()):
--> 204 exchanges, activities = self._efficient_write_dataset(
205 index, key, ds, exchanges, activities
206 )
~\Miniconda3\envs\tomaten\lib\site-packages\bw2data\backends\peewee\database.py in _efficient_write_dataset(self, index, key, ds, exchanges, activities)
154 for exchange in ds.get('exchanges', []):
155 if 'input' not in exchange or 'amount' not in exchange:
--> 156 raise InvalidExchange
157 if 'type' not in exchange:
158 raise UntypedExchange
InvalidExchange:
有谁知道是什么问题?
2) 我的计划有可能成功吗?我读到的下一个问题是未链接的交易所似乎是一个大问题,我所有的都是未链接的 atm。
先感谢您!