Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="prev" href="module-robotparser.html" /> | |
13 | <link rel="parent" href="netdata.html" /> | |
14 | <link rel="next" href="csv-contents.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>12.20 csv -- CSV File Reading and Writing</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="12.19 robotparser " | |
24 | href="module-robotparser.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" | |
27 | href="netdata.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="12.20.1 Module Contents" | |
30 | href="csv-contents.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Library Reference</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
37 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="module-robotparser.html">12.19 robotparser </A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="csv-contents.html">12.20.1 Module Contents</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION00142000000000000000000"> | |
55 | 12.20 <tt class="module">csv</tt> -- CSV File Reading and Writing</A> | |
56 | </H1> | |
57 | ||
58 | <P> | |
59 | <A NAME="module-csv"></A> | |
60 | ||
61 | <P> | |
62 | ||
63 | <span class="versionnote">New in version 2.3.</span> | |
64 | ||
65 | <a id='l2h-4212' xml:id='l2h-4212'></a> | |
66 | <a id='l2h-4211' xml:id='l2h-4211'></a> | |
67 | <P> | |
68 | The so-called CSV (Comma Separated Values) format is the most common import | |
69 | and export format for spreadsheets and databases. There is no ``CSV | |
70 | standard'', so the format is operationally defined by the many applications | |
71 | which read and write it. The lack of a standard means that subtle | |
72 | differences often exist in the data produced and consumed by different | |
73 | applications. These differences can make it annoying to process CSV files | |
74 | from multiple sources. Still, while the delimiters and quoting characters | |
75 | vary, the overall format is similar enough that it is possible to write a | |
76 | single module which can efficiently manipulate such data, hiding the details | |
77 | of reading and writing the data from the programmer. | |
78 | ||
79 | <P> | |
80 | The <tt class="module">csv</tt> module implements classes to read and write tabular data in | |
81 | CSV format. It allows programmers to say, ``write this data in the format | |
82 | preferred by Excel,'' or ``read data from this file which was generated by | |
83 | Excel,'' without knowing the precise details of the CSV format used by | |
84 | Excel. Programmers can also describe the CSV formats understood by other | |
85 | applications or define their own special-purpose CSV formats. | |
86 | ||
87 | <P> | |
88 | The <tt class="module">csv</tt> module's <tt class="class">reader</tt> and <tt class="class">writer</tt> objects read and | |
89 | write sequences. Programmers can also read and write data in dictionary | |
90 | form using the <tt class="class">DictReader</tt> and <tt class="class">DictWriter</tt> classes. | |
91 | ||
92 | <P> | |
93 | <div class="note"><b class="label">Note:</b> | |
94 | This version of the <tt class="module">csv</tt> module doesn't support Unicode | |
95 | input. Also, there are currently some issues regarding ASCII NUL | |
96 | characters. Accordingly, all input should generally be printable | |
97 | ASCII to be safe. These restrictions will be removed in the future. | |
98 | </div> | |
99 | ||
100 | <P> | |
101 | <div class="seealso"> | |
102 | <p class="heading">See Also:</p> | |
103 | ||
104 | <dl compact="compact" class="seerfc"> | |
105 | <dt><a href="http://www.python.org/peps/pep-0305.html" | |
106 | title="CSV File API" | |
107 | >PEP 305, <em>CSV File API</em></a> | |
108 | <dd>The Python Enhancement Proposal which proposed this addition | |
109 | to Python. | |
110 | </dl> | |
111 | </div> | |
112 | ||
113 | <P> | |
114 | ||
115 | <p><br /></p><hr class='online-navigation' /> | |
116 | <div class='online-navigation'> | |
117 | <!--Table of Child-Links--> | |
118 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
119 | ||
120 | <UL CLASS="ChildLinks"> | |
121 | <LI><A href="csv-contents.html">12.20.1 Module Contents</a> | |
122 | <LI><A href="csv-fmt-params.html">12.20.2 Dialects and Formatting Parameters</a> | |
123 | <LI><A href="node634.html">12.20.3 Reader Objects</a> | |
124 | <LI><A href="node635.html">12.20.4 Writer Objects</a> | |
125 | <LI><A href="node636.html">12.20.5 Examples</a> | |
126 | </ul> | |
127 | <!--End of Table of Child-Links--> | |
128 | </div> | |
129 | ||
130 | <DIV CLASS="navigation"> | |
131 | <div class='online-navigation'> | |
132 | <p></p><hr /> | |
133 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
134 | <tr> | |
135 | <td class='online-navigation'><a rel="prev" title="12.19 robotparser " | |
136 | href="module-robotparser.html"><img src='../icons/previous.png' | |
137 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
138 | <td class='online-navigation'><a rel="parent" title="12. Internet Data Handling" | |
139 | href="netdata.html"><img src='../icons/up.png' | |
140 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
141 | <td class='online-navigation'><a rel="next" title="12.20.1 Module Contents" | |
142 | href="csv-contents.html"><img src='../icons/next.png' | |
143 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
144 | <td align="center" width="100%">Python Library Reference</td> | |
145 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
146 | href="contents.html"><img src='../icons/contents.png' | |
147 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
148 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
149 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
150 | <td class='online-navigation'><a rel="index" title="Index" | |
151 | href="genindex.html"><img src='../icons/index.png' | |
152 | border='0' height='32' alt='Index' width='32' /></A></td> | |
153 | </tr></table> | |
154 | <div class='online-navigation'> | |
155 | <b class="navlabel">Previous:</b> | |
156 | <a class="sectref" rel="prev" href="module-robotparser.html">12.19 robotparser </A> | |
157 | <b class="navlabel">Up:</b> | |
158 | <a class="sectref" rel="parent" href="netdata.html">12. Internet Data Handling</A> | |
159 | <b class="navlabel">Next:</b> | |
160 | <a class="sectref" rel="next" href="csv-contents.html">12.20.1 Module Contents</A> | |
161 | </div> | |
162 | </div> | |
163 | <hr /> | |
164 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
165 | </DIV> | |
166 | <!--End of Navigation Panel--> | |
167 | <ADDRESS> | |
168 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
169 | </ADDRESS> | |
170 | </BODY> | |
171 | </HTML> |