summaryrefslogtreecommitdiffstats
path: root/openbb_terminal
diff options
context:
space:
mode:
authorSandip Saha <sandipsmoto@gmail.com>2023-10-30 08:40:41 +0530
committerGitHub <noreply@github.com>2023-10-30 03:10:41 +0000
commit195bc057bb1cfee3df8b34f48309c8344ee31465 (patch)
treef6660c959681110b07bdbe6001e1c328f5ff6198 /openbb_terminal
parentb4db72f5e856e378ee662015868225ca0f4abc8d (diff)
Hotfix/econometrics export filename fix (#5508)
* fix: Modify 'load' behavior to append data to existing sheet Details: - Added logic to detect existing sheet and append data if present. - There is no direct way to append on the sheet, so I am reading the sheet to get the last row number and then writing after that row number. Resolves: #5472 * Added --export option for exporting to a desired file in /econometrics menu * Added a -f/--file option to provide the filename for export. Made -t/--type and -f/--file mutually exclusive. If -f is not given, -t is required and the filename will be generated based on the time and module. * Revert `helper_funcs.py` to original state * Made some arguments not required. * Minor changes asked by @deeleeramone * No sheet name * black --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Diffstat (limited to 'openbb_terminal')
-rw-r--r--openbb_terminal/econometrics/econometrics_controller.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/openbb_terminal/econometrics/econometrics_controller.py b/openbb_terminal/econometrics/econometrics_controller.py
index e4c6ff9ba96..315deaccb44 100644
--- a/openbb_terminal/econometrics/econometrics_controller.py
+++ b/openbb_terminal/econometrics/econometrics_controller.py
@@ -458,7 +458,15 @@ class EconometricsController(BaseController):
type=str,
)
- parser.add_argument(
+ export_group = parser.add_mutually_exclusive_group(required=False)
+ export_group.add_argument(
+ "-f",
+ "--file",
+ dest="file",
+ help="The name of the file you wish to export to",
+ type=str,
+ )
+ export_group.add_argument(
"-t",
"--type",
help="The file type you wish to export to",
@@ -471,7 +479,7 @@ class EconometricsController(BaseController):
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-n")
ns_parser = self.parse_known_args_and_warn(
- parser, other_args, export_allowed=NO_EXPORT
+ parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser:
@@ -479,10 +487,13 @@ class EconometricsController(BaseController):
console.print("Please enter a valid dataset.")
else:
export_data(
- ns_parser.type,
+ ns_parser.file if ns_parser.file else ns_parser.type,
os.path.dirname(os.path.abspath(__file__)),
ns_parser.name,
self.datasets[ns_parser.name],
+ sheet_name=" ".join(ns_parser.sheet_name)
+ if ns_parser.sheet_name
+ else None,
)
console.print()