Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added appabuild/data/__init__.py
Empty file.
35 changes: 19 additions & 16 deletions appabuild/database/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import csv
import json
import os
import pkgutil
import re
from io import StringIO
from pathlib import Path
from typing import Optional

import bw2data as bd
Expand All @@ -25,7 +28,7 @@
from appabuild.exceptions import BwDatabaseError, SerializedDataError
from appabuild.logger import log_validation_error, logger

PATH_TO_METHODS = "data/methods/ecoinvent_3.11_methods.csv"
DATA_MODULE = "appabuild.data"


class Database:
Expand Down Expand Up @@ -105,21 +108,21 @@ def import_in_project(self) -> None:
ei_bio_database = bd.Database(self.biosphere_name)

if not self.with_ecoinvent:
with open(PATH_TO_METHODS, newline="") as csvfile:
reader = csv.reader(csvfile, delimiter=";")
for row in reader:
method, category, indicator, unit = row
key = self.name, method, category, indicator
# todo add all empty methods
# key = self.name = tuple csv
if key not in bd.methods:
method = bd.Method(key)
method.register(
unit=unit,
filepath=PATH_TO_METHODS,
ecoinvent_version="3.11",
database=self.name,
)
data = pkgutil.get_data(DATA_MODULE, "methods/ecoinvent_3.11_methods.csv")
reader = csv.reader(StringIO(data.decode()), delimiter=";")
for row in reader:
method, category, indicator, unit = row
key = self.name, method, category, indicator
# todo add all empty methods
# key = self.name = tuple csv
if key not in bd.methods:
method = bd.Method(key)
method.register(
unit=unit,
filepath="methods/ecoinvent_3.11_methods.csv",
ecoinvent_version="3.11",
database=self.name,
)

for method in bd.methods:
bio_dataset = {
Expand Down