Track 8 · Lesson 6 of 11
Writing CSV files
Produce correct CSV files with csv.writer and csv.DictWriter: headers, automatic quoting, newline="" and missing or extra fields.
You will be able to
- Write rows with csv.writer and writerow()/writerows(), opening the file with newline=""
- Explain how the csv module quotes values containing commas, quotes or line breaks
- Write dictionaries with csv.DictWriter, a fixed column order and writeheader()
- Control missing and extra keys with restval and extrasaction
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.