Skip to content
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

Hotfix/econometrics export filename fix #5508

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openbb_terminal/econometrics/econometrics_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,15 @@ def call_export(self, other_args: List[str]):
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_BOTH_RAW_DATA_AND_FIGURES
ssahaxd marked this conversation as resolved.
Show resolved Hide resolved
)

if ns_parser:
if not ns_parser.name or ns_parser.name not in self.datasets:
console.print("Please enter a valid dataset.")
deeleeramone marked this conversation as resolved.
Show resolved Hide resolved
else:
export_data(
ns_parser.type,
ns_parser.export if ns_parser.export != "" else ns_parser.type,
os.path.dirname(os.path.abspath(__file__)),
ns_parser.name,
self.datasets[ns_parser.name],
deeleeramone marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
17 changes: 15 additions & 2 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,15 +1602,28 @@ def export_data(
)

elif saved_path.exists():
# Load the Excel file to get the existing data
existing_df = pd.read_excel(saved_path, sheet_name=sheet_name)
# Get the number of rows in the existing data
start_row = (
existing_df.shape[0] + 1
) # Add 1 to start writing after the last row

# Append data to the existing sheet
with pd.ExcelWriter(
saved_path,
mode="a",
if_sheet_exists="new",
if_sheet_exists="overlay",
engine="openpyxl",
) as writer:
df.to_excel(
writer, sheet_name=sheet_name, index=True, header=True
writer,
sheet_name=sheet_name,
startrow=start_row,
index=True,
header=False,
)

else:
with pd.ExcelWriter(
saved_path,
Expand Down