From e2d7036e82e2857f98437ab0c37a3afcf02747e9 Mon Sep 17 00:00:00 2001 From: Ben Adida <ben@adida.net> Date: Mon, 17 Feb 2014 22:01:17 -0800 Subject: [PATCH] added some fixes for weird newlines in csv uploads --- helios/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helios/models.py b/helios/models.py index e532f92..67f0895 100644 --- a/helios/models.py +++ b/helios/models.py @@ -673,6 +673,12 @@ class VoterFile(models.Model): else: content = self.voter_file_content + # now we have to handle non-universal-newline stuff + # we do this in a simple way: replace all \r with \n + # then, replace all double \n with single \n + # this should leave us with only \n + content = content.replace('\r','\n').replace('\n\n','\n') + voter_stream = io.BytesIO(content) else: voter_stream = open(self.voter_file.path, "rU") -- GitLab