iode.execute_report
- iode.execute_report(filepath: str | Path, parameters: str | List[str] = None)[source]
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 >>> from pathlib import Path >>> output_dir = getfixture('tmp_path') >>> create_var_rep = str(output_dir / "create_var.rep") >>> result_var_file = str(output_dir / "test_var.av")
>>> # 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(f"$WsSaveVar {result_var_file}\n") 12 24 22 22 25 26 ...
>>> # execute report >>> execute_report(create_var_rep, ["A", "B", "C", "D"]) iode> $WsClearVar iode> $WsSample 2000Y1 2005Y1 iode> $DataCalcVar A t+1 iode> $DataCalcVar B t-1 iode> $DataCalcVar C A/B iode> $DataCalcVar D grt A iode> $WsSaveVar ...test_var.av Saving ...test_var.av
>>> # check content of file test_var.av >>> with open(result_var_file, "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