12.20.4 Writer Objects

Writer objects (DictWriter instances and objects returned by the writer() function) have the following public methods. A row must be a sequence of strings or numbers for Writer objects and a dictionary mapping fieldnames to strings or numbers (by passing them through str() first) for DictWriter objects. Note that complex numbers are written out surrounded by parens. This may cause some problems for other programs which read CSV files (assuming they support complex numbers at all).

writerow( row)
Write the row parameter to the writer's file object, formatted according to the current dialect.

writerows( rows)
Write all the rows parameters (a list of row objects as described above) to the writer's file object, formatted according to the current dialect.

Writer objects have the following public attribute:

dialect
A read-only description of the dialect in use by the writer.

See About this document... for information on suggesting changes.