REGISTER NOW: DdS Autumn School! 🇨🇭 Grosshöchstetten (Switzerland) 🗓️ 6.-11. October 2024

bw2io.export.excel#

Module Contents#

Functions#

create_valid_worksheet_name(string)

Exclude invalid characters and names.

lci_matrices_to_excel(database_name[, include_descendants])

Export LCI matrices to Excel.

write_lci_excel(database_name[, objs, sections, dirpath])

Export database database_name to an Excel spreadsheet.

write_lci_matching(db, database_name[, only_unlinked, ...])

Write matched and unmatched exchanges to Excel file

write_lcia_matching(db, name)

Write matched and unmatched CFs to Excel file

bw2io.export.excel.create_valid_worksheet_name(string)[source]#

Exclude invalid characters and names.

Parameters#

stringstr

String to convert to a valid worksheet name.

Returns#

stringstr

Valid worksheet name.

Notes#

Data from http://www.accountingweb.com/technology/excel/seven-characters-you-cant-use-in-worksheet-names.

bw2io.export.excel.lci_matrices_to_excel(database_name, include_descendants=True)[source]#

Export LCI matrices to Excel.

Parameters#

database_namestr

Name of database to export.

include_descendantsbool

Include databases which are linked from database_name. (default True)

Returns#

filepathstr

Path to created Excel file.

Examples#

>>> lci_matrices_to_excel(database_name='example_db', include_descendants=True)
'/path/to/example_db.xlsx'
bw2io.export.excel.write_lci_excel(database_name, objs=None, sections=None, dirpath=None)[source]#

Export database database_name to an Excel spreadsheet.

Notes#

Not all data can be exported. The following constraints apply:

  • Nested data, e.g. {‘foo’: {‘bar’: ‘baz’}} are excluded.

  • Spreadsheets are not a great format for nested data. However, tuples are exported, and the characters :: are used to join elements of the tuple.

  • The only well-supported data types are strings, numbers, and booleans.

Default directory is projects.output_dir, set dirpath to have save the file somewhere else.

Parameters#

database_namestr

Name of the database to export.

objslist, optional

List of objects to export. If not provided, all objects in the database will be exported.

sectionslist, optional

List of sections to export. If not provided, all sections will be exported.

dirpathstr, optional

Directory to save the file to. Default is projects.output_dir.

Returns#

str

Filepath of the exported file.

bw2io.export.excel.write_lci_matching(db, database_name, only_unlinked=False, only_activity_names=False)[source]#

Write matched and unmatched exchanges to Excel file

Parameters#

dbbw2data.Database

Database to write.

database_namestr

Name of the database to write.

only_unlinkedbool, optional

Only write unlinked exchanges. Default is False.

only_activity_namesbool, optional

Only write activity names. Default is False.

Returns#

str

Filepath of the exported file.

bw2io.export.excel.write_lcia_matching(db, name)[source]#

Write matched and unmatched CFs to Excel file

Parameters#

dbbw2data.Database

Database to write.

namestr

Name of the database to write.

Returns#

str

Filepath of the exported file.