Skip to main content

A Python package that converts ecospold XML formats to their Python equivalents and export the same data back to XML.

Project description

pyecospold

PyPI Status Python Version License

Read the documentation at https://pyecospold.readthedocs.io/ Tests Codecov

pre-commit Black

Installation

You can install pyecospold via [pip] from [PyPI]:

$ pip install pyecospold

ecospold1 Schema Updates

1.1

This library includes a new version of the schema definitions for ecospold1. Version 1.1 includes the following changes:

  • Changed the length restriction on referenceFunction.name to 255
  • Changed the length restriction on referenceFunction.synonym to 255
  • Changed the length restriction on category and subCategory to 255
  • Changed the length restriction on representativeness.productionVolume to 32.000
  • Made telephone optional

These changes were based on how this schema was being used by LCA software.

1.2

Corrected the handling of CAS numbers based on the official documentation:

  • A fixed size isn't required, zero-padding is optional and in any case is not used consistently by LCA software
  • Maximum length is 12, not 11
  • The first element has a minimum size of 2 digits, not 1

Usage

from pyecospold import parse_file, save_file, Defaults

# Override defaults if needed, else skip. Defaults are already set.
Defaults.config("config.ini")  # Replace with your own config file

# Parse the required XML file to EcoSpold class.
ecoSpold = parse_file("data/v1/v1_1.xml")  # Replace with your own XML file
ecoSpold
>> <Element {http://www.EcoInvent.org/EcoSpold01}ecoSpold at 0x24a558b6020>

# Change whatever attributes you need changing.
referenceFunction = ecoSpold.dataset.metaInformation.processInformation.referenceFunction
referenceFunction.amount = 2.0
referenceFunction.amount
>> 2.0

# Save final EcoSpold class as an XML file, make sure root directory exists.
save_file(ecoSpold, "out/00001_new.xml")  # Replace with your own path

Config file

[parameters]
SCHEMA_V1_FILE=path/to/schemas/v1/EcoSpold01Dataset.xsd
SCHEMA_V2_FILE=path/to/schemas/v2/EcoSpold02.xsd

[Allocation]
allocationMethod=-1

[DataEntryBy]
qualityNetwork=1

[Dataset]
validCompanyCodes=CompanyCodes.xml
validRegionalCodes=RegionalCodes.xml
validCategories=Categories.xml
validUnits=Units.xml

[DataSetInformation]
impactAssessmentResult=false
internalVersion=1.0
version=1.0

[Exchange]
uncertaintyType=1

[ReferenceFunction]
infrastructureProcess=true

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the BSD license, pyecospold is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyecospold-3.2.0.tar.gz (127.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyecospold-3.2.0-py3-none-any.whl (137.2 kB view details)

Uploaded Python 3

File details

Details for the file pyecospold-3.2.0.tar.gz.

File metadata

  • Download URL: pyecospold-3.2.0.tar.gz
  • Upload date:
  • Size: 127.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pyecospold-3.2.0.tar.gz
Algorithm Hash digest
SHA256 3454254e252a0eae7a9b86395e792bb73ed9db7cc714743988b4b10abe525587
MD5 54b911982c78159883a4b305b819ac81
BLAKE2b-256 896581ec1bc31668acf9db376ad9fdfbebc0c95853305925c29724d7f15fe2a7

See more details on using hashes here.

File details

Details for the file pyecospold-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyecospold-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 137.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pyecospold-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee0b1b99726115e7c33b59006054f65e5233988e03a26f3aa524f3e9182c9cf5
MD5 6dba14917e7753dbefca5f29459a34b8
BLAKE2b-256 19ed528d5af2d1ca1a08eff85256c24a09ac7ba2b2ef826578568d61c44165b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page