Commits

Colin Copeland committed 78ae249

excel dialect

Comments (0)

Files changed (1)

 def compare_membership_list(request, compare_id):
     compare = get_object_or_404(members.MembershipComparison, pk=compare_id)
     fh = open(compare.file.path)
-    has_header = csv.Sniffer().sniff(fh.read(1024))
+    try:
+        dialect = csv.Sniffer().sniff(fh.read(1024))
+    except csv.Error:
+        dialect = csv.excel
     fh.seek(0)
     csv_reader = csv.reader(fh)
     lines = []
                 for attr, index in columns:
                     row.append(line[index])
                 second.append(', '.join(row))
-            if has_header:
-                second.pop(0)
             
             diff = '\n'.join(difflib.ndiff(first, second))
             output = highlight(diff, DiffLexer(), HtmlFormatter())
     return {
         'output': output,
         'lines': lines,
-        'has_header': has_header,
+        'has_header': dialect,
         'form': form,
         'compare': compare,
     }