OpenSlides/openslides/utils/csv_ext.py

24 lines
611 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from csv import Dialect, excel, register_dialect
2012-07-10 13:19:12 +02:00
class excel_semikolon(Dialect):
delimiter = ';'
doublequote = True
lineterminator = '\r\n'
quotechar = '"'
quoting = 0
skipinitialspace = False
2012-07-10 13:19:12 +02:00
def patchup(dialect):
if dialect:
if dialect.delimiter in [excel_semikolon.delimiter, excel.delimiter] and \
dialect.quotechar == excel_semikolon.quotechar:
# walks like a duck and talks like a duck.. must be one
dialect.doublequote = True
return dialect
register_dialect("excel_semikolon", excel_semikolon)