How can I export results via Python?

Category:
Scripting
Summary

This example showcases how to export results stored in result objects via Python. It includes an example project to showcase the export to a csv file.

Answer

The contents of result objects (ElmRes) are exported via the Result Export command (ComRes). This command offers various options:

  • Export type (e.g. csv, COMTRADE, txt, databases)
  • Option to export all or only certain result variables of specific elements
  • Customizations for column headers, number formats, intervals

The attached project contains an example script in the Scripts folder of the project library. Before executing the script, the path of the folder to which the results should be exported to needs to be adapted on the Basic Options page of the script.

The script performs a sensitivity analysis and then exports the results as a csv file with the name "MyResultExport.csv" to the target folder. The code contains examples on how to change settings of the result export and how to selectively export specific result variables.

This approach works for calculation results that are stored in result objects. Some calculations in PowerFactory (e.g. load flow or short circuit) do not store their results in result objects. The result variables for such calculations can be directly accessed from the individual network elements via Python.

Back