Writing data to a SimaPro CSV import file

Importing data back to SimaPro is done by creating a SimaPro csv import file. This file is simply generated by filling a file template with process data. Templating is done using the Jinja2 package.

This is done using SimaProCsvWriter and its method to_csv().

from eldam.core.simapro import SimaProCsvWriter

SimaProCsvWriter(process1, process2, elda_only_data=True).to_csv('path/to/file.csv')

The argument elda_only_data lets choose if the data only used by ELDAM and not by SimaPro should be embedded in comments or not. Default value is True.

The csv file must then be imported back in SimaPro with File/Import, setting the parameters as shown below:


Parameter conflict:

The SimaProCsvWriter class can be instantiated with one or many processes, as it is possible to export multiple processes in a single csv. In that case, database/project level parameters conflicts can happen. If several processes has database/project level parameters with the same names but not the same data, a ParameterConflictError is raised with conflictual parameters as arguments. To avoid this exception, SimaProCsvWriter class’s constructor accepts an argument named chosen_parameters which is a list of parameters that will replace any database/project level parameters of the same name.

from eldam.core.simapro import SimaProCsvWriter

    csv_writer = SimaProCsvWriter(process1, process2)
except ParameterConflictError as conflict_error:
    conflicts = conflict_error.arg[0]
    chosen_parameters = [conflict[0] for conflict in conflicts]
    csv_writer = SimaProCsvWriter(process1, process2, chosen_parameters=chosen_parameters)