From 551b8bfd380946d8f5fed899885391c0ff780533 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Wed, 7 Feb 2024 16:04:39 +0100 Subject: [PATCH] Allow results to be converted to excel format --- src/otoole/cli.py | 2 +- src/otoole/convert.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/otoole/cli.py b/src/otoole/cli.py index c0305f74..e1d971a1 100644 --- a/src/otoole/cli.py +++ b/src/otoole/cli.py @@ -172,7 +172,7 @@ def get_parser(): result_parser.add_argument( "to_format", help="Result data format to convert to", - choices=sorted(["csv"]), + choices=sorted(["csv", "excel"]), ) result_parser.add_argument( "from_path", help="Path to file or folder to convert from" diff --git a/src/otoole/convert.py b/src/otoole/convert.py index 3cecd343..b1f1886a 100644 --- a/src/otoole/convert.py +++ b/src/otoole/convert.py @@ -90,7 +90,7 @@ def convert_results( from_format : str Available options are 'cbc', 'cplex' and 'gurobi' to_format : str - Available options are 'csv' + Available options are 'csv', 'excel' from_path : str Path to cbc, cplex or gurobi solution file to_path : str @@ -125,7 +125,11 @@ def convert_results( write_defaults = True if write_defaults else False if to_format == "csv": - write_strategy = WriteCsv( + write_strategy: WriteStrategy = WriteCsv( + user_config=user_config, write_defaults=write_defaults + ) + elif to_format == "excel": + write_strategy = WriteExcel( user_config=user_config, write_defaults=write_defaults ) else: