Metadata-Version: 2.4
Name: crrispi-exporter
Version: 1.0.2
Summary: Export a Brightway process hierarchy for CRRiSPI analysis
Author-email: "tools4env.com" <contact@crrispi.com>
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: bw2data<5,>=4
Requires-Dist: pandas>=1.5
Requires-Dist: openpyxl>=3.1
Requires-Dist: tomli>=2.0; python_version < "3.11"

# CRRiSPI Brightway Exporter

A small command-line tool that exports a Brightway process hierarchy to the
Excel format expected by CRRiSPI.

## Features

- Interactive discovery of Brightway projects and databases.
- Interactive root-activity search by process name, product, geography, or code.
- Extraction of the following schema:
  `Process`, `Product`, `Geography`, `Level`, `Amount`, `Custom`.
- Non-interactive command-line mode for scripts and repeatable workflows.
- Existing custom-process/original-process matching and hierarchy expansion logic.

## Install

Activate the same Python/conda environment in which Brightway is installed,
then run from this repository:

```bash
python -m pip install crrispi-exporter
```

## Interactive mode

```bash
crrispi-export
```

You can also supply some values and let the tool prompt only for the rest:

```bash
crrispi-export --project "RETURN project test"
```

The interactive activity selector searches the selected root database by:

- process name
- reference product
- geography/location
- Brightway activity code

It displays at most 25 matches at a time; refine the search when needed.

## Fully non-interactive mode

```bash
crrispi-export \
  --non-interactive \
  --project "RETURN project test" \
  --reference-database "ecoinvent-3.12-cutoff" \
  --root-database "crrispi" \
  --root-code "4c386ad0b3192f3c8f15034309db210e_copy1" \
  --functional-unit 1.0 \
  --output ./CRRiSPI_Brightway_Export.xlsx \
```

In non-interactive mode these four settings are required, either on the command
line or in a config file:

- project name
- reference database
- root database
- root activity code

`functional_unit` and `output_file` have defaults.

## TOML configuration

Create `crrispi-export.toml`:

```toml
[crrispi]
project_name = "RETURN project test"
reference_database = "ecoinvent-3.12-cutoff"
root_database = "crrispi"
root_activity_code = "4c386ad0b3192f3c8f15034309db210e_copy1"
functional_unit = 1.0
output_file = "CRRiSPI_Brightway_Export.xlsx"
```

Then run:

```bash
crrispi-export --config crrispi-export.toml --non-interactive
```

Config files can also be combined with interactive mode:

```bash
crrispi-export --config crrispi-export.toml
```

If required fields are absent, they are prompted for.

CLI arguments override config-file values. For example:

```bash
crrispi-export \
  --config crrispi-export.toml \
  --functional-unit 10 \
  --output ./export-10kg.xlsx \
  --non-interactive
```
