Skip to content Skip to sidebar Skip to footer

What Exactly Are The Csv Module's Dialect Settings For Excel-tab?

The csv module implements classes to read and write tabular data in CSV format. It allows programmers to say, “write this data in the format preferred by Excel,” or “re

Solution 1:

Going straight to the source of Lib/csv.py, excel-tab has all the properties of excel, plus a tab-delimiter.

class excel(Dialect):
    """Describe the usual properties of Excel-generated CSV files."""
    delimiter = ','
    quotechar = '"'
    doublequote = True
    skipinitialspace = False
    lineterminator = '\r\n'
    quoting = QUOTE_MINIMAL
register_dialect("excel", excel)

class excel_tab(excel):
    """Describe the usual properties of Excel-generated TAB-delimited files."""
    delimiter = '\t'
register_dialect("excel-tab", excel_tab)

Post a Comment for "What Exactly Are The Csv Module's Dialect Settings For Excel-tab?"