Skip to content

Commit

Permalink
allow StreamImpactItem to be created from datasheets
Browse files Browse the repository at this point in the history
  • Loading branch information
yalinli2 committed Oct 12, 2023
1 parent e8821b1 commit eaeb620
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qsdsan/_impact_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down

0 comments on commit eaeb620

Please sign in to comment.