|
33 | 33 | """ |
34 | 34 |
|
35 | 35 | import ast |
36 | | -import csv |
37 | 36 | from dataclasses import dataclass |
38 | 37 | import logging |
39 | 38 | import numbers |
@@ -965,16 +964,17 @@ def simulate_cmd( |
965 | 964 | if simargs: |
966 | 965 | om_cmd.args_set(args=simargs) |
967 | 966 |
|
968 | | - overrideFile = self._tempdir / f"{self._model_name}_override.txt" |
969 | 967 | if self._override_variables or self._simulate_options_override: |
970 | | - tmpdict = self._override_variables.copy() |
971 | | - tmpdict.update(self._simulate_options_override) |
972 | | - # write to override file |
973 | | - with open(file=overrideFile, mode="w", encoding="utf-8") as fh: |
974 | | - for key, value in tmpdict.items(): |
975 | | - fh.write(f"{key}={value}\n") |
| 968 | + override_file = result_file.parent / f"{result_file.stem}_override.txt" |
976 | 969 |
|
977 | | - om_cmd.arg_set(key="overrideFile", val=overrideFile.as_posix()) |
| 970 | + override_content = ( |
| 971 | + "\n".join([f"{key}={value}" for key, value in self._override_variables.items()]) |
| 972 | + + "\n".join([f"{key}={value}" for key, value in self._simulate_options_override.items()]) |
| 973 | + + "\n" |
| 974 | + ) |
| 975 | + |
| 976 | + override_file.write_text(override_content) |
| 977 | + om_cmd.arg_set(key="overrideFile", val=override_file.as_posix()) |
978 | 978 |
|
979 | 979 | if self._inputs: # if model has input quantities |
980 | 980 | for key in self._inputs: |
@@ -1432,9 +1432,10 @@ def _createCSVData(self, csvfile: Optional[pathlib.Path] = None) -> pathlib.Path |
1432 | 1432 | if csvfile is None: |
1433 | 1433 | csvfile = self._tempdir / f'{self._model_name}.csv' |
1434 | 1434 |
|
1435 | | - with open(file=csvfile, mode="w", encoding="utf-8", newline="") as fh: |
1436 | | - writer = csv.writer(fh) |
1437 | | - writer.writerows(csv_rows) |
| 1435 | + # basic definition of a CSV file using csv_rows as input |
| 1436 | + csv_content = "\n".join([",".join(map(str, row)) for row in csv_rows]) + "\n" |
| 1437 | + |
| 1438 | + csvfile.write_text(csv_content) |
1438 | 1439 |
|
1439 | 1440 | return csvfile |
1440 | 1441 |
|
|
0 commit comments