Skip to content

Commit

Permalink
feat: add BOM to batch zip csv
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Nov 17, 2023
1 parent c3756a3 commit 4f009cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/benefit/applications/services/csv_export_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def write_csv_file(self, path) -> None:

def get_csv_string(self, remove_quotes: bool = False) -> str:
return "".join( # Lines end with '\r\n' already so no need to add newlines here
self.get_csv_string_lines_generator(remove_quotes=remove_quotes)
self.get_csv_string_lines_generator(remove_quotes=remove_quotes, add_bom=True)
)

def get_csv_cell_list_lines_generator(
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_csv_string_lines_generator(

for line in self.get_csv_cell_list_lines_generator():
line_length_set.add(len(line))
assert len(line_length_set) == 1, "Each CSV line must have same colum count"
assert len(line_length_set) == 1, "Each CSV line must have same column count"
csv_writer.writerow(line)
yield io.getvalue()
# Reset StringIO object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_talpa_csv_output(pruned_applications_csv_service_with_one_application):
pruned_applications_csv_service_with_one_application.get_csv_string()
)
# BOM at the beginning of the file
assert csv_lines[0][0] == '"Hakemusnumero"'
assert csv_lines[0][0] == '\ufeff"Hakemusnumero"'
csv_columns = iter(pruned_applications_csv_service_with_one_application.CSV_COLUMNS)
next(csv_columns, None) # Skip the first element

Expand Down

0 comments on commit 4f009cf

Please sign in to comment.