bw2io.export.csv#

Module Contents#

Classes#

CSVFormatter

Functions#

reformat(value)

write_lci_csv(database_name[, objs, sections])

Export database database_name to a CSV file.

Attributes#

EXCHANGE_COLUMNS

MAPPING

PARAMETER_COLUMNS

class bw2io.export.csv.CSVFormatter(database_name, objs=None)[source]#

Bases: object

exchange_as_dict(exc)[source]#
get_activity(act)[source]#
get_activity_metadata(act)[source]#
get_activity_parameters(act)[source]#
get_database_metadata()[source]#
get_database_parameters()[source]#
get_exchanges(act)[source]#
get_formatted_data(sections=None)[source]#
get_project_parameters()[source]#
get_unformatted_data()[source]#

Return all database data as a nested dictionary:

{
    'database': {
        'name': name,
        'metadata': [(key, value)],
        'parameters': {
            'columns': [column names],
            'data': [[column values for each row]]
        },
        'project parameters': {
            'columns': [column names],
            'data': [[column values for each row]]
        }
    },
    'activities': [{
        'name': name,
        'metadata': [(key, value)],
        'parameters': {
            'columns': [column names],
            'group': 'group name',
            'data': [[column values for each row]]
        },
        'exchanges': {
            'columns': [column names],
            'data': [[column values for each row]]
        }
    }]
}
order_dicts(data, kind='exchange')[source]#
bw2io.export.csv.reformat(value)[source]#
bw2io.export.csv.write_lci_csv(database_name, objs=None, sections=None)[source]#

Export database database_name to a CSV file.

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

  • Nested data, e.g. {‘foo’: {‘bar’: ‘baz’}} are excluded. CSV is 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.

Returns the filepath of the exported file.

bw2io.export.csv.EXCHANGE_COLUMNS = ['name', 'amount', 'database', 'location', 'unit', 'categories', 'type', 'formula', 'uncertainty...[source]#
bw2io.export.csv.MAPPING[source]#
bw2io.export.csv.PARAMETER_COLUMNS = ['name', 'amount', 'formula', 'uncertainty type', 'loc', 'scale', 'shape', 'minimum', 'maximum'][source]#