mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
#5975: add unix_dialect to csv module.
This commit is contained in:
parent
347fe5ce3c
commit
7424dd359c
4 changed files with 32 additions and 2 deletions
12
Lib/csv.py
12
Lib/csv.py
|
|
@ -20,7 +20,7 @@ __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
|
|||
"unregister_dialect", "__version__", "DictReader", "DictWriter" ]
|
||||
|
||||
class Dialect:
|
||||
"""Describe an Excel dialect.
|
||||
"""Describe a CSV dialect.
|
||||
|
||||
This must be subclassed (see csv.excel). Valid attributes are:
|
||||
delimiter, quotechar, escapechar, doublequote, skipinitialspace,
|
||||
|
|
@ -65,6 +65,16 @@ class excel_tab(excel):
|
|||
delimiter = '\t'
|
||||
register_dialect("excel-tab", excel_tab)
|
||||
|
||||
class unix_dialect(Dialect):
|
||||
"""Describe the usual properties of Unix-generated CSV files."""
|
||||
delimiter = ','
|
||||
quotechar = '"'
|
||||
doublequote = True
|
||||
skipinitialspace = False
|
||||
lineterminator = '\n'
|
||||
quoting = QUOTE_ALL
|
||||
register_dialect("unix", unix_dialect)
|
||||
|
||||
|
||||
class DictReader:
|
||||
def __init__(self, f, fieldnames=None, restkey=None, restval=None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue