Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
CSV dialects
6. Dialects for CSV writing
Summary

Instruction

Great work!

The good news is that using dialects when writing data into a CSV file is pretty much the same. Take a look:

data_to_write = ...
with open('filename.csv', mode='w', newline='') as csv_file:
  csv_writer = csv.writer(csv_file, dialect='excel-tab')
  csv_writer.writerows(data_to_write)

Again, all we need to do is add the dialect parameter when invoking csv.writer() or csv.DictWriter().

Exercise

Write the data from the template into a CSV file named houses.csv. Add a header row to the first line. Use the unix CSV dialect.

Stuck? Here's a hint!

To write the header row, use: csv_writer.writeheader().