Skip to content

Commit

Permalink
Add date and time to scenario difference file name.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Apr 8, 2024
1 parent 03add0b commit e4c028f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions premise/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit e4c028f

Please sign in to comment.