GreenDelta / spm2olca

A simple command line tool that converts a SimaPro LCIA method files a olca-schema (JSON-LD) package.
MIT License
0 stars 1 forks source link

Read delimiter of method file from file header #1

Open msrocka opened 7 years ago

msrocka commented 7 years ago

Currently only semicolons are supported but this could be read from the file header:

{SimaPro 8.1.1.22}
{methods}
{Date: 2017/07/26}
{Time: 23:35:26}
{Project: idea v2 - methods}
{CSV Format version: 8.0.5}
{CSV separator: Semicolon}           <---
{Decimal separator: .}
{Date separator: /}
msrocka commented 5 years ago

also, it cannot handle the case when there are semicolons in the names ...

jsvmonsjou commented 5 years ago

Hello Michael, Is this code still functional with the updates from simapro and openlca of this year? When I try to convert and import these .csv files and then import as an 'impact assessment method' with JSON-LD format no (visible) changes are made. Could you point me in the direction i should be looking to solve this? Thank you

csv method files: SBK_CML.zip SBK_EDIP_radioactive_waste_corrected.zip

output spm2olca out_SBK_CML.zip

log from openlca OpenLCA_import_SBK_CML_log.txt

msrocka commented 5 years ago

@jsvmonsjou I only checked the SBK_CML.CSV file. When I open it with a text editor the file looks like this:

{Library 'Ecoinvent 3 - allocation, cut-off by classification - unit'};;;;;
;;;;;
Method;;;;;
;;;;;
Name;;;;;
SBK Bepalingsmethode, 25 mei 2018 (NMD 2.2);;;;;
;;;;;
Version;;;;;

... lots of trailing ;;;;;. When I remove them e.g. via Notepad++ ...

image

... I get this error:

es\spm2olca\model.py", line 115, in parse_impact_factor
    f.value = float(parts[4].replace(',', '.'))
ValueError: could not convert string to float: 'Catchement Brisbane River'

this is because spm2olca is not smart enough to handle semicolons in flow names. Fortunatelly, there was only one flow "Water, river; GIS: ;Catchement Brisbane River; Country: AU" with semicolons in the name. When I replace them with commas, the conversion works and I could import the result into openLCA:

image

hope this helps

jsvmonsjou commented 5 years ago

Thank you so much for investigating! The steps you described I managed to replicate. Conversion by spm2olca now works! thank you! The only problem I encounter now is that no impacts are shown/calculated. General information, Impact Factors, and Normalization and Weighting seem correct in the impact assessment method. Would you have any idea what I am overlooking at the moment?

image

msrocka commented 5 years ago

@jsvmonsjou late response, sorry... maybe this is related to missing flow mappings? See the readme file for instructions how to apply mappings in the conversion.