Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/write/csv_writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pandas as pd
from pandas import DataFrame

from os import makedirs
from os.path import exists, dirname

from src.constants import OUTPUT_FILE_PATH, FILE_PATH


Expand All @@ -22,5 +25,9 @@ def get_output_file_path(self):
return result

def write_csv(self, df: DataFrame):
df.to_csv(self.get_output_file_path(), index=False)
output_file_path = self.get_output_file_path()
if not exists(dirname(output_file_path)):
makedirs(dirname(output_file_path), exist_ok=True)

df.to_csv(output_file_path, index=False)
print("Anonymized csv has been successfully created!")