From eaeb620cc4e03cb5766832f6a4b9059b25efc5d5 Mon Sep 17 00:00:00 2001 From: Yalin Date: Thu, 12 Oct 2023 09:52:41 -0400 Subject: [PATCH] allow `StreamImpactItem` to be created from datasheets --- qsdsan/_impact_item.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qsdsan/_impact_item.py b/qsdsan/_impact_item.py index c7705908..98fc476a 100644 --- a/qsdsan/_impact_item.py +++ b/qsdsan/_impact_item.py @@ -383,8 +383,12 @@ def get_item(cls, ID): @classmethod def _load_from_df(cls, name, df): if name.lower() == 'info': + if 'kind' not in df.columns: df['kind'] = 'ImpactItem' for num in df.index: - new = cls.__new__(cls) + kind = df.iloc[num].kind.lower() + if kind == 'streamimpactitem': + new = StreamImpactItem.__new__(StreamImpactItem) + else: new = cls.__new__(cls) new.__init__(ID=df.iloc[num].ID, functional_unit=df.iloc[num].functional_unit) else: @@ -409,8 +413,9 @@ def load_from_file(cls, path_or_dict, index_col=None): This Excel should have multiple sheets: - - The "info" sheet should have two columns: "ID" (e.g., Cement) \ - and "functional_unit" (e.g., kg) of different impact items. + - The "info" sheet should have three columns: "ID" (e.g., Cement) \ + "functional_unit" (e.g., kg), and "kind" ("ImpactItem" or "StreamImpactItem") + of different impact items. - The remaining sheets should contain characterization factors of \ impact indicators.