screenshot of an exchange causing problemI'm desperately attempting to import my Excel spreadsheet into my project in Brightway2, but I first encountered an error due to unique unlinked exchanges. This issue stems from having multiple product activities. To address this, I added a "reference product" column to differentiate my activities, which are meant to be linked to the ecoinvent 3.9.1 cutoff database. Then, I adjusted my importing strategies by adding reference product as follows:
imp = bw.ExcelImporter("my_database")
imp.apply_strategies()
imp.match_database("ecoinvent 3.9.1 cutoff", fields=('name','unit','location', 'reference product'))
#imp.match_database(fields=('name', 'unit', 'location', 'reference product'))
imp.statistics()
What am I overlooking here? Do I also need to specify a reference product for those activities that have no relation to ecoinvent? such as biosphere, and to those that I created?
Below, you can find the complete type error message:
Cell In[193], line 5
3 imp.match_database("ecoinvent 3.9.1 cutoff", fields=('name','unit','location', 'reference product'))
4 #imp.match_database(fields=('name', 'unit', 'location', 'reference product'))
----> 5 imp.statistics()
File ~/opt/.../base_lci.py:69, in LCIImporter.statistics(self, print_stats)
67 for exc in (e for e in ds.get("exchanges", []) if not e.get("input")):
68 unique_unlinked[exc.get("type")].add(activity_hash(exc))
---> 69 unique_unlinked = sorted(
70 [(k, len(v)) for k, v in list(unique_unlinked.items())]
71 )
73 print(
74 (
75 u"{} datasets\n{} exchanges\n{} unlinked exchanges\n "
(...)
82 ).format(num_datasets, num_exchanges, num_unlinked)
83 )
84 return num_datasets, num_exchanges, num_unlinked
TypeError: '<' not supported between instances of 'NoneType' and 'str'
I tried various import strategies to handle this issue. But I couldn't import my database.
The error says
TypeError: '<' not supported between instances of 'NoneType' and 'str'. I suspect is because you are using as matching field "reference product" which is only defined for some activities (so it is a None for the case reference product field and a string in other cases).