Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
CSV dialects
4. Checking parameter values for built-in dialects


Great! We know there are three built-in CSV dialects, but what are the differences between them? Each CSV dialect contains the following seven parameters:

  1. delimiter – the field separator.
  2. quotechar – the character that surrounds fields with special values.
  3. doublequote – a True/False parameter that controls whether quotechar instances should be doubled.
  4. escapechar – an optional character used before special characters.
  5. lineterminator – the string used to terminate a line.
  6. quoting – a parameter that describes when fields should be surrounded with quote characters.
  7. skipinitialspace – a True/False parameter that indicates whether to ignore whitespaces after field delimiters

You can check the values of specific parameters for a given dialect in the following way:

import csv
print('delimiter:', csv.excel.delimiter)
print('quotechar:', csv.excel.quotechar)

Let's take a look at the parameters of the excel dialect:

delimiter: ,
quotechar: "
doublequote: True
escapechar: None
skipinitialspace: False
lineterminator: '\r\n'

Incidentally, the excel-tab dialect only differs in the delimiter parameter, which is '\t' (a tab).


We'd like to list all seven parameters of the unix dialect in the same way and order as shown in the explanation. We've already written proper prints for six of these parameters, so your job is to correct only the last print.

Hint: to get the literal character used for line termination, for example, use the repr() function.

As you can see, the unix dialect is somewhat different from both excel and excel-tab. The quoting: 1 value corresponds to QUOTE_ALL – so in this dialect, all fields are surrounded with the quotechar.

Stuck? Here's a hint!

Just change "fix that line" to: