Skip to main content

ILCD Lib


Python library providing parsing capabilities for ILCD XML files.

Installation

Install the library from PyPi. The following command will install the library with all optional dependencies:

pip install "ilcdlib[lxml,cli]"

If you don't need CLI tool, you can omit cli extra. The following extras are available:

  • lxml - install lxml library for faster XML parsing
  • cli - install CLI tool so it could be used from command line via ilcdtool command.

Python's zoneinfo needs an IANA time zone database, which is not bundled with Python or installed by ilcdlib. On Windows or in minimal container images without system time zone data, install tzdata in your application environment to avoid ZoneInfoNotFoundError, including when using the default UTC time zone:

pip install tzdata

Usage

CLI

At the moment the primary function of the CLI tool is to convert ILCD XML files to openEPD (json) format.

Here is a simple example of how to use it to convert ILCD archive to openEPD format:

ilcdtool --debug convert-epd -i ilcd+epd -o openEPD "<path/to/archive.zip>"

It is also possible to point the tool to the http endpoint instead. At the moment Soda4Lca web UI and api endpoints are supported.

ilcdtool convert-epd -i ilcd+epd -o openEPD "https://oekobaudat.de/OEKOBAU.DAT/datasetdetail/process.xhtml?uuid=ee8863aa-7276-4896-b07a-713937a3134d&version=00.00.018&stock=OBD_2021_II&lang=en"

Another important feature is the ability to specify a dialect. Dialect is a set of rules that define how the handle provider specific data. It is useful for the cases when provider does not follow the standard or standard is not strict enough the provider has a multiple options how to persist the data.

convert-epd -i ilcd+epd -o openEPD -d environdec https://data.environdec.com/showProcess.xhtml?uuid=bfeb8678-b3cb-4a5b-b8cb-2512b551ad17&version=01.00.001&stock=Environdata

CLI tool provides comprehensive help for each of the supported commands. Use ilcdtool --help to get the list of the supported commands and a set of global parameters. And use ilcdtool <command> --help to get help for the specific command.

Use in Python code

There are 3 primary concepts in the library:

  1. Medium is a way how application reads ILCD XML data. It could be a zip file, some http API or anything else.
  2. IlcdXmlReader is a class that reads ILCD XML data from the medium and provides a set of methods to access the data.
  3. Dialects are just a subclasses of corresponding readers which override data extraction logic for some of the fields.

So very basic usage of the library would look like this:

from ilcdlib.epd.reader import IlcdEpdReader
from ilcdlib.medium.archive import ZipIlcdReader

lang = ["en", None]  # Means "en" or any available language

# Create a medium capable to read data from the zip archive
zip_reader = ZipIlcdReader("<path/to/archive.zip>")
# Create a reader that will read data from the given medium and passing the target object to read 
# (identified by id and version)
epd_reader = IlcdEpdReader(
    "2eb43850-0ab2-4068-afe5-218d69a096f8",
    "00.01.000",
    zip_reader,
)

print(epd_reader.get_product_name(lang))  # Extract product name
print(epd_reader.get_declared_unit())  # Extract declared unit  

# Convert to openEPD format
print(epd_reader.to_openepd_epd(lang).model_dump_json(indent=2))

For Library Maintainers

Maintainer's Guide is available here.

Credits

This library has been written and maintained by C-Change Labs.

License

This library is licensed under Apache 2. This means you are free to use it in commercial projects.

Metadata

Release files for ilcdlib 5.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ilcdlib 5.5.1
File Size Uploaded
ilcdlib-5.5.1.tar.gz 223.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ilcdlib 5.5.1
File Interpreter ABI Platform
ilcdlib-5.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 486.7 kB

Release files / ilcdlib-5.5.1.tar.gz

Download URL ilcdlib-5.5.1.tar.gz
Size 223.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f4eca45dc892d3ff9f1f2732d7e53ff378886cd745f672aa91ae840bb8ea330b
BLAKE2b-256 checksum
How to use checksums
1d1d175ce9252bb6b0d4ee9fe6e3af8d6147f957dc8bddff2c03d287de24643b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.17 Linux/6.17.0-1022-azure

Release files / ilcdlib-5.5.1-py3-none-any.whl

Download URL ilcdlib-5.5.1-py3-none-any.whl
Size 263.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46ff3835b6bf6ffd8eb5841ed400343fea7d731bdc1d85f81b04953f2d15b035
BLAKE2b-256 checksum
How to use checksums
cf5af4f4f34d1a27eb070c6e06d18e0aa4f1421f57b3d55d5bb0782588d1148a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.17 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

5.5.3

2 release files

5.5.2

2 release files

This release

5.5.1 This release

2 release files

5.5.0

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.2

2 release files

5.0.1

2 release files

4.13.0

2 release files

4.11.3

2 release files

4.11.2

2 release files

4.11.1

2 release files

4.10.0

2 release files

4.9.0

2 release files

4.8.0

2 release files

4.7.0

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page