Skip to content

Commit

Permalink
Allow custom output path for write_lci_matching
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Sep 4, 2024
1 parent 94f97d0 commit 7b1f074
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bw2io/export/excel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path
from typing import Optional, List
import collections
import numbers
import os
Expand Down Expand Up @@ -287,7 +289,7 @@ def write_lci_excel(database_name, objs=None, sections=None, dirpath=None):


def write_lci_matching(
db, database_name, only_unlinked=False, only_activity_names=False
db: List[dict], database_name: str, only_unlinked: bool=False, only_activity_names: bool=False, output_dir: Optional[Path] = None
):
"""
Write matched and unmatched exchanges to Excel file
Expand Down Expand Up @@ -353,10 +355,9 @@ def write_row(sheet, row, data, exc=True):
)

safe_name = safe_filename(database_name, False)
suffix = "-unlinked" if only_unlinked else "-names" if only_activity_names else ""
filepath = os.path.join(
projects.output_dir, "db-matching-" + safe_name + suffix + ".xlsx"
)
suffix = "-unlinked" if only_unlinked else ("-names" if only_activity_names else "")

filepath = Path(output_dir or projects.output_dir) / f"db-matching-{safe_name}{suffix}.xlsx"

workbook = xlsxwriter.Workbook(filepath)
bold = workbook.add_format({"bold": True})
Expand Down

0 comments on commit 7b1f074

Please sign in to comment.