From e4c028f87b75f56e5f841dae18560a3e3f938c25 Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Mon, 8 Apr 2024 16:09:13 +0200 Subject: [PATCH] Add date and time to scenario difference file name. --- premise/export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/premise/export.py b/premise/export.py index c966c236..ec03d91b 100644 --- a/premise/export.py +++ b/premise/export.py @@ -14,6 +14,7 @@ from multiprocessing.pool import ThreadPool as Pool from pathlib import Path from typing import Any, Dict, List +from datetime import datetime import numpy as np import pandas as pd @@ -883,13 +884,13 @@ def generate_superstructure_db( ) if file_format == "excel": - filepath_sdf = filepath / f"scenario_diff_{db_name}.xlsx" + filepath_sdf = filepath / f"scenario_diff_{db_name}_{datetime.now()}.xlsx" df.to_excel(filepath_sdf, index=False) elif file_format == "csv": - filepath_sdf = filepath / f"scenario_diff_{db_name}.csv" + filepath_sdf = filepath / f"scenario_diff_{db_name}_{datetime.now()}.csv" df.to_csv(filepath_sdf, index=False, sep=";", encoding="utf-8-sig") elif file_format == "feather": - filepath_sdf = filepath / f"scenario_diff_{db_name}.feather" + filepath_sdf = filepath / f"scenario_diff_{db_name}_{datetime.now()}.feather" df.to_feather(filepath_sdf) else: raise ValueError(f"Unknown format {file_format}")