Skip to content

Commit

Permalink
Download records as excel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lumburovskalina committed Nov 4, 2024
1 parent 0456f99 commit f922923
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions controller/transfer/export_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from util.sql_helper import parse_sql_text

ILLEGAL_CHARACTER_REG_EX = r"[\000-\010]|[\013-\014]|[\016-\037]"


def parse(
project_id: str,
Expand Down Expand Up @@ -43,6 +45,10 @@ def parse(
elif file_type == enums.RecordExportFileTypes.CSV.value:
df.to_csv(file_path, index=False)
elif file_type == enums.RecordExportFileTypes.XLSX.value:
for column in df.columns:
type_name = df[column].dtype.name
if type_name == "object":
df[column] = df[column].str.replace(ILLEGAL_CHARACTER_REG_EX, "")
df.to_excel(file_path)
else:
message = f"File type {file_type} not supported."
Expand Down
2 changes: 1 addition & 1 deletion submodules/model
Submodule model updated 1 files
+1 −1 session.py

0 comments on commit f922923

Please sign in to comment.