[Python-checkins] python/nondist/sandbox/csv _csv.c,1.17,1.18
andrewmcnamara@users.sourceforge.net
andrewmcnamara@users.sourceforge.net
Thu, 06 Feb 2003 18:36:28 -0800
Update of /cvsroot/python/python/nondist/sandbox/csv
In directory sc8-pr-cvs1:/tmp/cvs-serv12758
Modified Files:
_csv.c
Log Message:
Updated module docstring to match current API.
Index: _csv.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/_csv.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** _csv.c 7 Feb 2003 01:27:21 -0000 1.17
--- _csv.c 7 Feb 2003 02:36:25 -0000 1.18
***************
*** 1111,1155 ****
*/
- static struct PyMethodDef csv_methods[] = {
- { "reader", (PyCFunction)csv_reader, METH_VARARGS | METH_KEYWORDS},
- { "writer", (PyCFunction)csv_writer, METH_VARARGS | METH_KEYWORDS},
- { "list_dialects", (PyCFunction)csv_list_dialects, METH_VARARGS},
- { "register_dialect", (PyCFunction)csv_register_dialect, METH_VARARGS},
- { "unregister_dialect", (PyCFunction)csv_unregister_dialect, METH_VARARGS},
- { "get_dialect", (PyCFunction)csv_get_dialect, METH_VARARGS},
- { NULL, NULL }
- };
-
PyDoc_STRVAR(csv_module_doc,
! "This module provides class for performing CSV parsing and writing.\n"
"\n"
! "The CSV parser object (returned by the parser() function) supports the\n"
! "following methods:\n"
! " clear()\n"
! " Discards all fields parsed so far. If autoclear is set to\n"
! " zero. You should call this after a parser exception.\n"
"\n"
- " parse(string) -> list of strings\n"
- " Extracts fields from the (partial) CSV record in string.\n"
- " Trailing end of line characters are ignored, so you do not\n"
- " need to strip the string before passing it to the parser. If\n"
- " you pass more than a single line of text, a _csv.Error\n"
- " exception will be raised.\n"
"\n"
! " join(sequence) -> string\n"
! " Construct a CSV record from a sequence of fields. Non-string\n"
! " elements will be converted to string.\n"
"\n"
! "Typical usage:\n"
"\n"
! " import _csv\n"
! " p = _csv.parser()\n"
! " fp = open('afile.csv', 'U')\n"
! " for line in fp:\n"
! " fields = p.parse(line)\n"
! " if not fields:\n"
! " # multi-line record\n"
! " continue\n"
! " # process the fields\n");
PyMODINIT_FUNC
--- 1111,1229 ----
*/
PyDoc_STRVAR(csv_module_doc,
! "CSV parsing and writing.\n"
"\n"
! "This module provides classes that assist in the reading and writing\n"
! "of Comma Separated Value (CSV) files, and implements the interface\n"
! "described by PEP 305. Although many CSV files are simple to parse,\n"
! "the format is not formally defined by a stable specification and\n"
! "is subtle enough that parsing lines of a CSV file with something\n"
! "like line.split(\",\") is bound to fail. The module supports three\n"
! "basic APIs: reading, writing, and registration of dialects.\n"
"\n"
"\n"
! "READING:\n"
"\n"
! "The reader interface is provided by a factory function \"reader\":\n"
"\n"
! " csv_reader = reader(iterable [, dialect='excel']\n"
! " [optional keyword args])\n"
! " for row in csv_reader:\n"
! " process(row)\n"
! "\n"
! "The \"iterable\" argument can be any object that returns a line\n"
! "of input for each iteration, such as a file object or a list. The\n"
! "optional \"dialect\" parameter is discussed below. The function\n"
! "also accepts optional keyword arguments which override settings\n"
! "provided by the dialect.\n"
! "\n"
! "The returned object is an iterator. Each iteration returns a row\n"
! "of the CSV file (which can span multiple input lines):\n"
! "\n"
! "\n"
! "WRITING:\n"
! "\n"
! "The writer interface is provided by a factory function \"writer\":\n"
! "\n"
! " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
! " [optional keyword args])\n"
! " for row in csv_writer:\n"
! " csv_writer.writerow(row)\n"
! "\n"
! " [or]\n"
! "\n"
! " csv_writer = csv.writer(fileobj [, dialect='excel']\n"
! " [optional keyword args])\n"
! " csv_writer.writerows(rows)\n"
! "\n"
! "The \"fileobj\" argument can be any object that supports the file API.\n"
! "\n"
! "\n"
! "DIALECT REGISTRATION:\n"
! "\n"
! "Readers and writers support a dialect argument, which is a convient\n"
! "handle on a group of settings. When the dialect argument is a string,\n"
! "it identifies one of the dialects registered with the module. If it\n"
! "is a class or instance, the attributes of the argument are used as the\n"
! "settings for the reader or writer:\n"
! "\n"
! " class excel:\n"
! " delimiter = ','\n"
! " quotechar = '\"'\n"
! " escapechar = None\n"
! " doublequote = True\n"
! " skipinitialspace = False\n"
! " lineterminator = '\r\n'\n"
! " quoting = QUOTE_MINIMAL\n"
! "\n"
! "The dialect registry is supported by four functions:\n"
! "\n"
! " list_dialects()\n"
! " register_dialect(name, dialect)\n"
! " unregister_dialect(name)\n"
! " get_dialect(name)\n"
! "\n"
! "SETTINGS:\n"
! "\n"
! " * quotechar - specifies a one-character string to use as the \n"
! " quoting character. It defaults to '\"'.\n"
! " * delimiter - specifies a one-character string to use as the \n"
! " field separator. It defaults to ','.\n"
! " * escapechar - specifies a one-character string used to escape \n"
! " the delimiter when quoting is set to QUOTE_NONE.\n"
! " * skipinitialspace - specifies how to interpret whitespace which\n"
! " immediately follows a delimiter. It defaults to False, which\n"
! " means that whitespace immediately following a delimiter is part\n"
! " of the following field.\n"
! " * lineterminator - specifies the character sequence which should \n"
! " terminate rows.\n"
! " * quoting - controls when quotes should be generated by the writer.\n"
! " It can take on any of the following module constants:\n"
! "\n"
! " csv.QUOTE_MINIMAL means only when required, for example, when a\n"
! " field contains either the quotechar or the delimiter\n"
! " csv.QUOTE_ALL means that quotes are always placed around fields.\n"
! " csv.QUOTE_NONNUMERIC means that quotes are always placed around\n"
! " fields which contain characters other than [+-0-9.].\n"
! " csv.QUOTE_NONE means that quotes are never placed around fields.\n"
! " * doublequote - controls the handling of quotes inside fields. When\n"
! " True two consecutive quotes are interpreted as one during read,\n"
! " and when writing, each quote is written as two quotes\n");
!
! static struct PyMethodDef csv_methods[] = {
! { "reader", (PyCFunction)csv_reader,
! METH_VARARGS | METH_KEYWORDS, csv_module_doc},
! { "writer", (PyCFunction)csv_writer,
! METH_VARARGS | METH_KEYWORDS, csv_module_doc},
! { "list_dialects", (PyCFunction)csv_list_dialects,
! METH_VARARGS, csv_module_doc},
! { "register_dialect", (PyCFunction)csv_register_dialect,
! METH_VARARGS, csv_module_doc},
! { "unregister_dialect", (PyCFunction)csv_unregister_dialect,
! METH_VARARGS, csv_module_doc},
! { "get_dialect", (PyCFunction)csv_get_dialect,
! METH_VARARGS, csv_module_doc},
! { NULL, NULL }
! };
PyMODINIT_FUNC