Browse Source

CSV

pull/44/head
Jure Šorn 5 years ago
parent
commit
8c82f7c266
2 changed files with 4 additions and 2 deletions
  1. 3
      README.md
  2. 3
      index.html

3
README.md

@ -1686,6 +1686,7 @@ import csv
```python
<reader> = csv.reader(<file>, dialect='excel', delimiter=',')
<list> = next(<reader>) # Returns next row as a list of strings.
<list> = list(<reader>) # Returns list of remaining rows.
```
* **File must be opened with `'newline=""'` argument, or newlines embedded inside quoted fields will not be interpreted correctly!**
@ -1693,7 +1694,7 @@ import csv
```python
<writer> = csv.writer(<file>, dialect='excel', delimiter=',')
<writer>.writerow(<collection>) # Encodes objects using `str(<el>)`.
<writer>.writerows(<coll_of_coll>)
<writer>.writerows(<coll_of_coll>) # Appends multiple rows.
```
* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added on platforms that use '\r\n' linendings!**

3
index.html

@ -1517,6 +1517,7 @@ shutil.copytree(from, to) <span class="hljs-comment"># Copies the entir
<div><h3 id="read">Read</h3><pre><code class="python language-python hljs">&lt;reader&gt; = csv.reader(&lt;file&gt;, dialect=<span class="hljs-string">'excel'</span>, delimiter=<span class="hljs-string">','</span>)
&lt;list&gt; = next(&lt;reader&gt;) <span class="hljs-comment"># Returns next row as a list of strings.</span>
&lt;list&gt; = list(&lt;reader&gt;) <span class="hljs-comment"># Returns list of remaining rows.</span>
</code></pre></div>
<ul>
@ -1524,7 +1525,7 @@ shutil.copytree(from, to) <span class="hljs-comment"># Copies the entir
</ul>
<div><h3 id="write">Write</h3><pre><code class="python language-python hljs">&lt;writer&gt; = csv.writer(&lt;file&gt;, dialect=<span class="hljs-string">'excel'</span>, delimiter=<span class="hljs-string">','</span>)
&lt;writer&gt;.writerow(&lt;collection&gt;) <span class="hljs-comment"># Encodes objects using `str(&lt;el&gt;)`.</span>
&lt;writer&gt;.writerows(&lt;coll_of_coll&gt;)
&lt;writer&gt;.writerows(&lt;coll_of_coll&gt;) <span class="hljs-comment"># Appends multiple rows.</span>
</code></pre></div>
<ul>

Loading…
Cancel
Save