bw2io.importers.excel#
Attributes#
Classes#
Generic CSV importer |
|
Generic Excel importer. |
Functions#
|
Return boolean if first cell in worksheet is not |
Module Contents#
- class bw2io.importers.excel.CSVImporter(filepath)[source]#
Bases:
ExcelImporter
Generic CSV importer
- class bw2io.importers.excel.ExcelImporter(filepath)[source]#
Bases:
bw2io.importers.base_lci.LCIImporter
Generic Excel importer.
Excel spreadsheet should follow the following format:
- ::
Project parameters <variable>, <formula>, <amount>, metadata
Database, <name of database> <database field name>, <database field value>
Parameters <variable>, <formula>, <amount>, metadata
Activity, <name of activity> <database field name>, <database field value> Exchanges <field name>, <field name>, <field name> <value>, <value>, <value> <value>, <value>, <value>
Neither project parameters, parameters, nor exchanges for each activity are required.
An activity is marked as finished with a blank line.
In general, data is imported without modification. However, the following transformations are applied:
Numbers are translated from text into actual numbers.
Tuples, separated in the cell by the
::
string, are reconstructed.True
andFalse
are transformed to boolean values.Fields with the value
(Unknown)
are dropped.
- get_labelled_section(sn, ws, index=0, transform=True)[source]#
Turn a list of rows into a list of dictionaries.
The first line of
ws
is the column labels. All subsequent rows are the data values. Missing columns are dropped.transform
is a boolean: perform CSV transformation functions likecsv_restore_tuples
.
- get_project_parameters(data)[source]#
Extract project parameters (variables and formulas).
Project parameters are a section that starts with a line with the string “project parameters” (case-insensitive) in the first cell, and ends with a blank line. There can be multiple project parameter sections.
- write_database(**kwargs)[source]#
Same as base
write_database
method, butactivate_parameters
is True by default.