Skip to content
Snippets Groups Projects
Commit 44ab08fb authored by Neda Moeini's avatar Neda Moeini
Browse files

Improve CSV file handling

parent b5752c22
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,9 @@ class CSVUploadForm(forms.Form):
self._validate_file_type(file)
# Step 2: Parse file and validate headers
csv_file = file.read().decode("utf-8").splitlines()
raw_data = file.read().decode("utf-8")
normalized_data = raw_data.replace('\r\n', '\n').replace('\r', '\n')
csv_file = normalized_data.splitlines()
reader = csv.DictReader(csv_file, delimiter=",")
fieldnames = reader.fieldnames if reader.fieldnames is not None else []
self._validate_headers(fieldnames)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment