bw2io.export.excel#
Functions#
|
Exclude invalid characters and names. |
|
Export LCI matrices to Excel. |
|
Export database database_name to an Excel spreadsheet. |
|
Write matched and unmatched exchanges to Excel file |
|
Write matched and unmatched CFs to Excel file |
Module Contents#
- bw2io.export.excel.create_valid_worksheet_name(string)[source]#
Exclude invalid characters and names.
- Parameters:
string (str) – String to convert to a valid worksheet name.
- Returns:
string – Valid worksheet name.
- Return type:
str
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_name (str) – Name of database to export.
include_descendants (bool) – Include databases which are linked from
database_name
. (default True)
- Returns:
filepath – Path to created Excel file.
- Return type:
str
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
, setdirpath
to have save the file somewhere else.- Parameters:
database_name (str) – Name of the database to export.
objs (list, optional) – List of objects to export. If not provided, all objects in the database will be exported.
sections (list, optional) – List of sections to export. If not provided, all sections will be exported.
dirpath (str, optional) – Directory to save the file to. Default is
projects.output_dir
.
- Returns:
Filepath of the exported file.
- Return type:
str
- bw2io.export.excel.write_lci_matching(db: List[dict], database_name: str, only_unlinked: bool = False, only_activity_names: bool = False, output_dir: pathlib.Path | None = None)[source]#
Write matched and unmatched exchanges to Excel file
- Parameters:
db (
bw2data.Database
) – Database to write.database_name (str) – Name of the database to write.
only_unlinked (bool, optional) – Only write unlinked exchanges. Default is
False
.only_activity_names (bool, optional) – Only write activity names. Default is
False
.
- Returns:
Filepath of the exported file.
- Return type:
str