iode.execute_report

iode.execute_report(filepath: str | Path, parameters: str | List[str] = None)

Execute an IODE report.

Parameters:
filepath: str, Path

Filepath of the IODE report to execute. The extension of the file must be .rep.

parameters: str or list(str), optional

Parameter(s) passed to the report. If multiple parameters are passed in one string, they must be separated by a whitespace. Default to None.

Notes

Equivalent to the IODE command $ReportExec

Examples

>>> from iode import execute_report, variables
>>> # create an dump report
>>> with open("create_var.rep", "w") as f:
...     f.write("$WsClearVar\n")
...     f.write("$WsSample 2000Y1 2005Y1\n")
...     f.write("$DataCalcVar %1% t+1 \n")
...     f.write("$DataCalcVar %2% t-1 \n")
...     f.write("$DataCalcVar %3% %1%/%2%\n")
...     f.write("$DataCalcVar %4% grt %1% \n")
...     f.write("$WsSaveVar test_var.av\n")
12
24
22
22
25
26
23
>>> # execute report
>>> execute_report("create_var.rep", ["A", "B", "C", "D"])
>>> # check content of file test_var.av
>>> with open("test_var.av", "r") as f:         
...     print(f.read())
sample 2000Y1 2005Y1
A 1 2 3 4 5 6
B -1 0 1 2 3 4
C -1 na 3 2 1.66666666666667 1.5
D na 100 50 33.3333333333333 25 20