Skip to content

Commit

Permalink
fix: new sitiming csv format (freeform name)
Browse files Browse the repository at this point in the history
  • Loading branch information
brownben committed Aug 7, 2024
1 parent 9593001 commit 7841816
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/src/utils/import_file/import_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@

field_names: dict[str, Columns] = {
"name": "name",
"name free format": "name",
"firstname": "firstName",
"givenname": "firstName",
"forenames": "firstName",
"surnames": "surname",
"surname": "surname",
"familyname": "surname",
"course": "course",
Expand Down Expand Up @@ -71,7 +74,15 @@ def identify_delimeter(file: str) -> Literal[",", ";"]:
def normalise_header(header: str) -> str:
"""Normalise case and characters in headings to make matching more reliable"""

return header.lower().strip().replace("-", "").replace("_", "").replace(" ", "")
return (
header.lower()
.strip()
.replace("-", "")
.replace("_", "")
.replace(" ", "")
.replace("(", "")
.replace(")", "")
)


def get_column_locations(header_row: list[str]) -> dict[Columns, int]:
Expand Down

0 comments on commit 7841816

Please sign in to comment.