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 :class:`~eldam.core.simapro.SimaProCsvWriter` and its method :meth:`~eldam.core.simapro.SimaProCsvWriter.to_csv`. .. code-block:: python 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: .. image:: ../_static/import_setup.PNG :name: Import setup :target: ../_static/import_setup.PNG Parameter conflict: ------------------- The :class:`~eldam.core.simapro.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 :class:`~eldam.utils.exceptions.ParameterConflictError` is raised with conflictual parameters as arguments. To avoid this exception, :class:`~eldam.core.simapro.SimaProCsvWriter` class's constructor accepts an argument named :attr:`chosen_parameters` which is a list of parameters that will replace any database/project level parameters of the same name. .. code-block:: python from eldam.core.simapro import SimaProCsvWriter try: 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)