CSV dialects


The csv module defines a number of "dialects", sets of attributes.

examples/csv/dialects.py
import csv

for dialect_name in csv.list_dialects():
    print(dialect_name)
    dialect = csv.get_dialect(dialect_name)
    for attribute_name in [
            'delimiter',
            'doublequote',
            'escapechar',
            'lineterminator',
            'quotechar',
            'quoting',
            'skipinitialspace',
            'strict',
        ]:
        attr = getattr(dialect, attribute_name)
        if attr == '\t':
            attr = '\\t'
        if attr == '\r\n':
            attr = '\\r\\n'
        print("  {:16} '{}'".format(attribute_name, attr))

excel
  delimiter        ','
  doublequote      'True'
  escapechar       'None'
  lineterminator   '\r\n'
  quotechar        '"'
  quoting          '0'
  skipinitialspace 'False'
  strict           'False'
excel-tab
  delimiter        '\t'
  doublequote      'True'
  escapechar       'None'
  lineterminator   '\r\n'
  quotechar        '"'
  quoting          '0'
  skipinitialspace 'False'
  strict           'False'
unix
  delimiter        ','
  doublequote      'True'
  escapechar       'None'
  lineterminator   '
'
  quotechar        '"'
  quoting          '1'
  skipinitialspace 'False'
  strict           'False'

Dialects of CSV files. See also: csv