Skip to content

Commit

Permalink
Merge pull request #63 from statisticsnorway/fix_saving_bug
Browse files Browse the repository at this point in the history
Fix saving bug
  • Loading branch information
LBiermann-ssb authored Oct 11, 2024
2 parents eaa9475 + bd1aa24 commit 6e0bb64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ssb-konjunk"
version = "0.1.12"
version = "0.1.13"
description = "SSB Konjunk"
authors = ["Edvard Garmannslund <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion src/ssb_konjunk/saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _structure_ssb_filepath(

# Handle versionizing or not.
if version_number is None:
file_path = f"{file_path}/{file_name}_{time_stamp}"
file_path = f"{file_path}/{file_name}_{time_stamp}_"
elif isinstance(version_number, int):
file_path = f"{file_path}/{file_name}_{time_stamp}_v{version_number}.{filetype}"
else:
Expand Down Expand Up @@ -324,6 +324,8 @@ def write_ssb_file(
version_number = _find_version_number(files, stable_version)

if version_number:
if file_path.endswith("_"):
file_path = file_path[:-1]
file_path = f"{file_path}_v{version_number}.{filetype}"

_save_df(df, file_path, filetype, fs, seperator, encoding)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_structure_ssb_filepath() -> None:

assert (
filename_2
== "ssb-reiseliv-korttid-data-produkt-prod/overnatting/inndata/min_fil_p2023_p2024"
== "ssb-reiseliv-korttid-data-produkt-prod/overnatting/inndata/min_fil_p2023_p2024_"
), filename_2

filename_3 = _structure_ssb_filepath(
Expand All @@ -65,7 +65,7 @@ def test_structure_ssb_filepath() -> None:

assert (
filename_3
== "ssb-reiseliv-korttid-data-produkt-prod/overnatting/inndata/mellommappe/min_fil_p2023_p2024"
== "ssb-reiseliv-korttid-data-produkt-prod/overnatting/inndata/mellommappe/min_fil_p2023_p2024_"
), filename_3

filename_4 = _structure_ssb_filepath(
Expand All @@ -81,7 +81,7 @@ def test_structure_ssb_filepath() -> None:

assert (
filename_4
== "ssb-reiseliv-korttid-data-produkt-prod/oppdrag/min_fil_p2023_p2024"
== "ssb-reiseliv-korttid-data-produkt-prod/oppdrag/min_fil_p2023_p2024_"
), filename_4

filename_5 = _structure_ssb_filepath(
Expand All @@ -97,7 +97,7 @@ def test_structure_ssb_filepath() -> None:

assert (
filename_5
== "ssb-reiseliv-korttid-data-produkt-prod/oppdrag/38-99/min_fil_p2023_p2024"
== "ssb-reiseliv-korttid-data-produkt-prod/oppdrag/38-99/min_fil_p2023_p2024_"
), filename_5


Expand Down

0 comments on commit 6e0bb64

Please sign in to comment.