Package: ilcdlib
ILCD LibPython library providing parsing capabilities for ILCD XML files.InstallationInstall the library from PyPi. The following command will install the library with all optional dependencies:pipinstall"ilcdlib[lxml,cli]"If you don't need CLI tool, you can omitcliextra. The following extras are available:lxml- install lxml library for faster XML parsingcli- install CLI tool so it could be used from command line viailcdtoolcommand.Usage❗ ATTENTION: Pick the right version. There are 2 versions of the library available:Use versionbelow2.0.0if your project uses Pydantic version below2.0.0Use version2.x.xor higher if your project uses Pydantic version2.0.0or aboveBranch 1.x.x is not maintained anymore, so if you don't use pydantic 2.x.x should be your choice.CLIAt 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--debugconvert-epd-iilcd+epd-oopenEPD"<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.ilcdtoolconvert-epd-iilcd+epd-oopenEPD"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 adialect. 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-iilcd+epd-oopenEPD-denvirondechttps://data.environdec.com/showProcess.xhtml?uuid=bfeb8678-b3cb-4a5b-b8cb-2512b551ad17&version=01.00.001&stock=EnvirondataCLI tool provides comprehensive help for each of the supported commands. Useilcdtool --helpto get the list of the
supported commands and a set of global parameters. And useilcdtool <command> --helpto get help for the specific
command.Use in Python codeThere are 3 primary concepts in the library:Mediumis a way how application reads ILCD XML data. It could be a zip file, some http API or anything else.IlcdXmlReaderis a class that reads ILCD XML data from the medium and provides a set of methods to access the data.Dialectsare 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:fromilcdlib.epd.readerimportIlcdEpdReaderfromilcdlib.medium.archiveimportZipIlcdReaderlang=["en",None]# Means "en" or any available language# Create a medium capable to read data from the zip archivezip_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 nameprint(epd_reader.get_declared_unit())# Extract declared unit# Convert to openEPD formatprint(epd_reader.to_openepd_epd(lang).json(indent=2))For Library MaintainersMaintainer's Guide is availablehere.CreditsThis library has been written and maintained byC-Change Labs.LicenseThis library is licensed underApache 2. This means you are free to use it in commercial projects.