Snatch any course you want for just $15! Go to “Courses” and find a course ↓
Writing CSV files


Great job! Two more parameters worth noting are quotechar and quoting:

with open('books.csv', mode='w', newline='') as csv_file:
  csv_writer = csv.writer(csv_file, fieldnames=['Author', 'Title', 'Pages'], quotechar="'", quoting=csv.QUOTE_ALL)
    for row in data_to_save:

quotechar denotes the character that will be used to quote the text we're writing to the CSV. quoting, on the other hand, allows us to specify when the csv.writer or csv.DictWriter should use quoting. Possible options are:

  1. csv.QUOTE_ALLeach field will be enclosed in quote characters.
  2. csv.QUOTE_NONNUMERIC – each field that is not a number (such as int or float) will be quoted.
  3. csv.QUOTE_MINIMAL – quoting will be used only where necessary (i.e., when the field contains the separator character).
  4. csv.QUOTE_NONEno quoting will take place; a given string will be written as is.


Modify the template code so that it uses the semicolon as its delimiter and applies quoting to all fields without exception.

Stuck? Here's a hint!

Use delimiter=';' and quoting=csv.QUOTE_ALL.