June 2019
Beginner to intermediate
770 pages
19h 24m
English
Creating multiple kinds of rows in a single file makes the format a bit more complex. The column titles must become a union of all the available column titles. Because of the possibility of name clashes between the various row types, we can either access rows by position (preventing us from simply using csv.DictReader) or we must invent a more sophisticated column title that combines class and attribute names.
The process is simpler if we provide each row with an extra column that acts as a class discriminator. This extra column shows us what type of object the row represents. The object's class name would work well for this. Here's how we might write blogs and posts to a single CSV file ...
Read now
Unlock full access