-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
6,199 additions
and
42 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "03251142-6347-4c3b-9dab-ca61b3b8a552", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import randonneur as rd\n", | ||
"from pathlib import Path\n", | ||
"import randonneur_data as rdata" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "3065cefd-ec8a-4d69-bc76-b45973abeba7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"registry = rdata.Registry()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "8b1cda58-092e-4897-b1bd-821ce19649f3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def write_for_version(version, base_path, filename, sheet_name, combined):\n", | ||
" df = pd.read_excel(\n", | ||
" base_path / filename,\n", | ||
" sheet_name\n", | ||
" ) \n", | ||
" data = [\n", | ||
" {\n", | ||
" 'source': {\n", | ||
" 'identifier': row['Simapro Process Identifier'],\n", | ||
" 'name': row['Simapro Process Name'],\n", | ||
" 'platform_id': row['PlatformID'],\n", | ||
" },\n", | ||
" 'target': {\n", | ||
" 'filename': row[combined].lower() + \".spold\",\n", | ||
" 'name': row['Activity Name'],\n", | ||
" 'location': row['Geography'],\n", | ||
" 'reference product': row['Reference Product Name'],\n", | ||
" 'unit': row['Unit'],\n", | ||
" }\n", | ||
" } \n", | ||
" for row in df.to_dict(orient='records')\n", | ||
" ]\n", | ||
" dp = rd.Datapackage(\n", | ||
" name=f\"simapro-ecoinvent-{version}-cutoff\",\n", | ||
" description=f\"Data migration file from SimaPro 9 to ecoinvent-{version}-cutoff generated by PRé and provided via request at https://support.simapro.com/s/contactsupport\",\n", | ||
" contributors=[\n", | ||
" {\"title\": \"PRé\", \"path\": \"https://pre-sustainability.com/\", \"role\": \"author\"},\n", | ||
" {\"title\": \"Chris Mutel\", \"path\": \"https://chris.mutel.org/\", \"role\": \"wrangler\"},\n", | ||
" ],\n", | ||
" mapping_source=rd.MappingConstants.SIMAPRO_CSV,\n", | ||
" mapping_target=rd.MappingConstants.ECOSPOLD2,\n", | ||
" version=\"2.0.0\",\n", | ||
" source_id=\"SimaPro-9\",\n", | ||
" target_id=f\"ecoinvent-{version}-cutoff\"\n", | ||
" )\n", | ||
" dp.add_data(\"replace\", data)\n", | ||
" return registry.add_file(dp.to_json(Path(f\"simapro-ecoinvent-{version}-cutoff.json\")), replace=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "9afb0067-7343-46b4-beed-1fe7491281d9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"base_path = Path('/Users/cmutel/Projects/SimaPro - ecoinvent mapping/')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "8c30c0c9-9296-4527-aa74-c81fa0c9e12f", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"PosixPath('/Users/cmutel/Code/randonneur_data/randonneur_data/data/simapro-ecoinvent-3.10-cutoff.xz')" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"write_for_version(\n", | ||
" version=\"3.10\", \n", | ||
" base_path=base_path, \n", | ||
" filename=\"ecoinvent 3.10 Cut-off - SimaPro mapping.xlsx\", \n", | ||
" sheet_name=\"Mapping_Results_2024-04-25\", \n", | ||
" combined='Activity_UUID_Product_UUID',\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dbd86fa4-6142-461f-aa90-0aa650a44e0d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"write_for_version(\n", | ||
" version=\"3.8\", \n", | ||
" base_path=base_path, \n", | ||
" filename='ecoinvent cut-off 3.8 - SimaPro mapping file.xlsx', \n", | ||
" sheet_name=\"ecoinventCut-off38-SimaPro\", \n", | ||
" combined='Activity UUID & Product UUID'\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "08b41875-d606-4320-961d-15ce1bd94124", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"write_for_version(\n", | ||
" version=\"3.9.1\", \n", | ||
" base_path=base_path, \n", | ||
" filename='Ecoinvent_391_SimaPro_Mapping_Results_2023-10-03.xlsx', \n", | ||
" sheet_name=\"Mapping_Results_2023-10-03\", \n", | ||
" combined='Activity_UUID_Product_UUID'\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 23, | ||
"id": "66d21bb6-14f5-41d2-9e80-f9fd8256fe0d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"`randonneur_data` registry with 3 files:\n", | ||
"\tsimapro-ecoinvent-3.10-cutoff\n", | ||
"\tsimapro-ecoinvent-3.8-cutoff\n", | ||
"\tsimapro-ecoinvent-3.9.1-cutoff" | ||
] | ||
}, | ||
"execution_count": 23, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"registry" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"Registry", | ||
) | ||
|
||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
|
||
|
||
import json | ||
|
Oops, something went wrong.