diff options
author | Skip Montanaro <skip@pobox.com> | 2003-04-24 18:47:31 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2003-04-24 18:47:31 (GMT) |
commit | 3bd3c8403a9481c601ce960498bdaf7c35f83c5b (patch) | |
tree | 3f967ef1c9997d490d4bee7083ceabfd6aa7083a /Doc/lib/libcsv.tex | |
parent | 50889239c3057004be819897921af021436e197d (diff) | |
download | cpython-3bd3c8403a9481c601ce960498bdaf7c35f83c5b.zip cpython-3bd3c8403a9481c601ce960498bdaf7c35f83c5b.tar.gz cpython-3bd3c8403a9481c601ce960498bdaf7c35f83c5b.tar.bz2 |
* minor tweaks relating to the package nature of the beast
* added an (incomplete) description of the utils.Sniffer class
Diffstat (limited to 'Doc/lib/libcsv.tex')
-rw-r--r-- | Doc/lib/libcsv.tex | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/Doc/lib/libcsv.tex b/Doc/lib/libcsv.tex index 283e401..ec2dbcb 100644 --- a/Doc/lib/libcsv.tex +++ b/Doc/lib/libcsv.tex @@ -2,6 +2,7 @@ \declaremodule{standard}{csv} \modulesynopsis{Write and read tabular data to and from delimited files.} +\sectionauthor{Skip Montanaro}{skip@pobox.com} \versionadded{2.3} \index{csv} @@ -18,21 +19,21 @@ vary, the overall format is similar enough that it is possible to write a single module which can efficiently manipulate such data, hiding the details of reading and writing the data from the programmer. -The \module{csv} module implements classes to read and write tabular data in +The \module{csv} package 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 ``read data from this file which was generated by Excel,'' without knowing the precise details of the CSV format used by Excel. Programmers can also describe the CSV formats understood by other applications or define their own special-purpose CSV formats. -The \module{csv} module's \class{reader} and \class{writer} objects read and +The \module{csv} package's \class{reader} and \class{writer} objects read and write sequences. Programmers can also read and write data in dictionary form using the \class{DictReader} and \class{DictWriter} classes. -\note{The first version of the \module{csv} module doesn't support Unicode +\note{The first version of the \module{csv} package doesn't support Unicode input. Also, there are currently some issues regarding \ASCII{} NUL -characters. Accordingly, all input should generally be plain \ASCII{} to be -safe. These restrictions will be removed in the future.} +characters. Accordingly, all input should generally be printable \ASCII{} +to be safe. These restrictions will be removed in the future.} \begin{seealso} % \seemodule{array}{Arrays of uniformly types numeric values.} @@ -42,10 +43,10 @@ safe. These restrictions will be removed in the future.} \end{seealso} -\subsection{Module Contents} +\subsection{Package Contents} -The \module{csv} module defines the following functions: +The \module{csv} package defines the following functions: \begin{funcdesc}{reader}{csvfile\optional{, dialect=\code{'excel'}\optional{, fmtparam}}} @@ -108,7 +109,7 @@ Return the names of all registered dialects. \end{funcdesc} -The \module{csv} module defines the following classes: +The \module{csv} package defines the following classes: \begin{classdesc}{DictReader}{csvfile, fieldnames\optional{, restkey=\code{None}\optional{, @@ -262,11 +263,33 @@ according to the current dialect. \end{methoddesc} +\subsection{Submodule \code{utils}} + +The \module{csv} package contains a \module{utils} submodule which defines +the following class. + +\begin{classdesc}{Sniffer}{\optional{sample=16384}} + +The \class{Sniffer} class is used to deduce the format of a CSV file. The +optional \var{sample} argument to the constructor specifies the number of +bytes to use when determining Dialect parameters. + +\begin{methoddesc}{sniff}{fileobj} +Analyze the next chunk of \var{fileobj} and return a \class{Dialect} class +reflecting the parameters found. +\end{methoddesc} + +\begin{methoddesc} + +\end{methoddesc} +\end{classdesc} + \subsection{Examples} The ``Hello, world'' of csv reading is \begin{verbatim} + import csv reader = csv.reader(file("some.csv")) for row in reader: print row @@ -275,6 +298,7 @@ The ``Hello, world'' of csv reading is The corresponding simplest possible writing example is \begin{verbatim} + import csv writer = csv.writer(file("some.csv", "w")) for row in someiterable: writer.writerow(row) |