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

Fix saving bug #63

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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