-
-
Notifications
You must be signed in to change notification settings - Fork 252
ENH: Add Monte Carlo outputs export to CSV/JSON (#242) #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
e51b221
fe7c69e
1c1c77a
ee4bab5
d0cc223
6503273
8eecdc9
a5e77a8
d91ae51
8735ed0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -601,12 +601,14 @@ def export_results(self, output_filename, output_format): | |||||
| if output_format == "json": | ||||||
| with open(f"{output_filename}.json", "w", encoding="utf-8") as f: | ||||||
| json.dump(txt_data, f, indent=4) | ||||||
| _SimMonitor.reprint(f"Results saved to {Path(output_filename)} as .json file") | ||||||
| elif output_format == "csv": | ||||||
| output_csv_header = txt_data[0].keys() | ||||||
| with open(f"{output_filename}.csv", "w", newline= "") as f: | ||||||
|
||||||
| with open(f"{output_filename}.csv", "w", newline= "") as f: | |
| with open(f"{output_filename}.csv", "w", newline="") as f: |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing input validation for output_format parameter. The method should validate that output_format is either "csv" or "json" and raise a ValueError with a helpful message if an unsupported format is provided. Currently, if an unsupported format is passed, the method silently does nothing, which could confuse users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think having this be two different functions export_results_to_csv and export_results_to_json would be cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential
IndexErroriftxt_datais empty. If the.outputs.txtfile is empty or contains only blank lines,txt_data[0]will raise anIndexError. Add validation to check thattxt_datais not empty before attempting to access its first element.