{
    "mode": "pydoc",
    "parameter": "csv",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/csv/json",
    "generated": "2026-06-02T15:47:38Z",
    "sections": {
        "NAME": {
            "content": "csv - CSV parsing and writing.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/csv.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides classes that assist in the reading and writing\nof Comma Separated Value (CSV) files, and implements the interface\ndescribed by PEP 305.  Although many CSV files are simple to parse,\nthe format is not formally defined by a stable specification and\nis subtle enough that parsing lines of a CSV file with something\nlike line.split(\",\") is bound to fail.  The module supports three\nbasic APIs: reading, writing, and registration of dialects.\n\n\nDIALECT REGISTRATION:\n\nReaders and writers support a dialect argument, which is a convenient\nhandle on a group of settings.  When the dialect argument is a string,\nit identifies one of the dialects previously registered with the module.\nIf it is a class or instance, the attributes of the argument are used as\nthe settings for the reader or writer:\n\nclass excel:\ndelimiter = ','\nquotechar = '\"'\nescapechar = None\ndoublequote = True\nskipinitialspace = False\nlineterminator = '\\r\\n'\nquoting = QUOTEMINIMAL\n\nSETTINGS:\n\n* quotechar - specifies a one-character string to use as the\nquoting character.  It defaults to '\"'.\n* delimiter - specifies a one-character string to use as the\nfield separator.  It defaults to ','.\n* skipinitialspace - specifies how to interpret spaces which\nimmediately follow a delimiter.  It defaults to False, which\nmeans that spaces immediately following a delimiter is part\nof the following field.\n* lineterminator -  specifies the character sequence which should\nterminate rows.\n* quoting - controls when quotes should be generated by the writer.\nIt can take on any of the following module constants:\n\ncsv.QUOTEMINIMAL means only when required, for example, when a\nfield contains either the quotechar or the delimiter\ncsv.QUOTEALL means that quotes are always placed around fields.\ncsv.QUOTENONNUMERIC means that quotes are always placed around\nfields which do not parse as integers or floating point\nnumbers.\ncsv.QUOTENONE means that quotes are never placed around fields.\n* escapechar - specifies a one-character string used to escape\nthe delimiter when quoting is set to QUOTENONE.\n* doublequote - controls the handling of quotes inside fields.  When\nTrue, two consecutive quotes are interpreted as one during read,\nand when writing, each quote character embedded in the data is\nwritten as two quotes\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.Exception(builtins.BaseException)\ncsv.Error\nbuiltins.object\nDialect\nexcel\nexceltab\nunixdialect\nDictReader\nDictWriter\nSniffer\n",
            "subsections": [
                {
                    "name": "class Dialect",
                    "content": "|  Describe a CSV dialect.\n|\n|  This must be subclassed (see csv.excel).  Valid attributes are:\n|  delimiter, quotechar, escapechar, doublequote, skipinitialspace,\n|  lineterminator, quoting.\n|\n|  Methods defined here:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  delimiter = None\n|\n|  doublequote = None\n|\n|  escapechar = None\n|\n|  lineterminator = None\n|\n|  quotechar = None\n|\n|  quoting = None\n|\n|  skipinitialspace = None\n"
                },
                {
                    "name": "class DictReader",
                    "content": "|  DictReader(f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, kwds)\n|\n|  Methods defined here:\n|\n|  init(self, f, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, kwds)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  iter(self)\n|\n|  next(self)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  fieldnames\n"
                },
                {
                    "name": "class DictWriter",
                    "content": "|  DictWriter(f, fieldnames, restval='', extrasaction='raise', dialect='excel', *args, kwds)\n|\n|  Methods defined here:\n|\n|  init(self, f, fieldnames, restval='', extrasaction='raise', dialect='excel', *args, kwds)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  writeheader(self)\n|\n|  writerow(self, rowdict)\n|\n|  writerows(self, rowdicts)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class Error",
                    "content": "|  Method resolution order:\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class Sniffer",
                    "content": "|  \"Sniffs\" the format of a CSV file (i.e. delimiter, quotechar)\n|  Returns a Dialect object.\n|\n|  Methods defined here:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  hasheader(self, sample)\n|\n|  sniff(self, sample, delimiters=None)\n|      Returns a dialect (or None) corresponding to the sample\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class excel",
                    "content": "|  Describe the usual properties of Excel-generated CSV files.\n|\n|  Method resolution order:\n|      excel\n|      Dialect\n|      builtins.object\n|\n|  Data and other attributes defined here:\n|\n|  delimiter = ','\n|\n|  doublequote = True\n|\n|  lineterminator = '\\r\\n'\n|\n|  quotechar = '\"'\n|\n|  quoting = 0\n|\n|  skipinitialspace = False\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Dialect:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from Dialect:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Dialect:\n|\n|  escapechar = None\n"
                },
                {
                    "name": "class excel_tab",
                    "content": "|  Describe the usual properties of Excel-generated TAB-delimited files.\n|\n|  Method resolution order:\n|      exceltab\n|      excel\n|      Dialect\n|      builtins.object\n|\n|  Data and other attributes defined here:\n|\n|  delimiter = '\\t'\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from excel:\n|\n|  doublequote = True\n|\n|  lineterminator = '\\r\\n'\n|\n|  quotechar = '\"'\n|\n|  quoting = 0\n|\n|  skipinitialspace = False\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Dialect:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from Dialect:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Dialect:\n|\n|  escapechar = None\n"
                },
                {
                    "name": "class unix_dialect",
                    "content": "|  Describe the usual properties of Unix-generated CSV files.\n|\n|  Method resolution order:\n|      unixdialect\n|      Dialect\n|      builtins.object\n|\n|  Data and other attributes defined here:\n|\n|  delimiter = ','\n|\n|  doublequote = True\n|\n|  lineterminator = '\\n'\n|\n|  quotechar = '\"'\n|\n|  quoting = 1\n|\n|  skipinitialspace = False\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Dialect:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from Dialect:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Dialect:\n|\n|  escapechar = None\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "field_size_limit",
                    "content": "Sets an upper limit on parsed fields.\ncsv.fieldsizelimit([limit])\n\nReturns old limit. If limit is not given, no new limit is set and\nthe old limit is returned\n"
                },
                {
                    "name": "get_dialect",
                    "content": "Return the dialect instance associated with name.\ndialect = csv.getdialect(name)\n"
                },
                {
                    "name": "list_dialects",
                    "content": "Return a list of all know dialect names.\nnames = csv.listdialects()\n"
                },
                {
                    "name": "reader",
                    "content": "csvreader = reader(iterable [, dialect='excel']\n[optional keyword args])\nfor row in csvreader:\nprocess(row)\n\nThe \"iterable\" argument can be any object that returns a line\nof input for each iteration, such as a file object or a list.  The\noptional \"dialect\" parameter is discussed below.  The function\nalso accepts optional keyword arguments which override settings\nprovided by the dialect.\n\nThe returned object is an iterator.  Each iteration returns a row\nof the CSV file (which can span multiple input lines).\n"
                },
                {
                    "name": "register_dialect",
                    "content": "Create a mapping from a string name to a dialect class.\ndialect = csv.registerdialect(name[, dialect[, fmtparams]])\n"
                },
                {
                    "name": "unregister_dialect",
                    "content": "Delete the name/dialect mapping associated with a string name.\ncsv.unregisterdialect(name)\n"
                },
                {
                    "name": "writer",
                    "content": "csvwriter = csv.writer(fileobj [, dialect='excel']\n[optional keyword args])\nfor row in sequence:\ncsvwriter.writerow(row)\n\n[or]\n\ncsvwriter = csv.writer(fileobj [, dialect='excel']\n[optional keyword args])\ncsvwriter.writerows(rows)\n\nThe \"fileobj\" argument can be any object that supports the file API.\n"
                }
            ]
        },
        "DATA": {
            "content": "QUOTEALL = 1\nQUOTEMINIMAL = 0\nQUOTENONE = 3\nQUOTENONNUMERIC = 2\nall = ['QUOTEMINIMAL', 'QUOTEALL', 'QUOTENONNUMERIC', 'QUOTENO...\n",
            "subsections": []
        },
        "VERSION": {
            "content": "1.0\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/csv.py\n\n",
            "subsections": []
        }
    },
    "summary": "csv - CSV parsing and writing.",
    "flags": [],
    "examples": [],
    "see_also": []
}