Website hosting service by Active-Venture.com
  

 Back to Index

12.20.2 Dialects and Formatting Parameters

To make it easier to specify the format of input and output records, specific formatting parameters are grouped together into dialects. A dialect is a subclass of the Dialect class having a set of specific methods and a single validate() method. When creating reader or writer objects, the programmer can specify a string or a subclass of the Dialect class as the dialect parameter. In addition to, or instead of, the dialect parameter, the programmer can also specify individual formatting parameters, which have the same names as the attributes defined below for the Dialect class.

Dialects support the following attributes:

delimiter
A one-character string used to separate fields. It defaults to ','.

 

doublequote
Controls how instances of quotechar appearing inside a field should be themselves be quoted. When True, the character is doubledd. When False, the escapechar must be a one-character string which is used as a prefix to the quotechar. It defaults to True.

 

escapechar
A one-character string used to escape the delimiter if quoting is set to QUOTE_NONE. It defaults to None.

 

lineterminator
The string used to terminate lines in the CSV file. It defaults to '\r\n'.

 

quotechar
A one-character string used to quote elements containing the delimiter or which start with the quotechar. It defaults to '"'.

 

quoting
Controls when quotes should be generated by the writer. It can take on any of the QUOTE_* constants (see section 12.20.1) and defaults to QUOTE_MINIMAL.

 

skipinitialspace
When True, whitespace immediately following the delimiter is ignored. The default is False.

  

 

2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Cheap domain name registration - Register domain name and domain transfer from $5.95/year only

 
Domain registration - Domain registration, domain name transfer and domain search services