Skip to content

Commit 53012f9

Browse files
committed
Csv
1 parent e9a0170 commit 53012f9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ def read_csv_file(filename):
14431443
with open(filename, encoding='utf-8', newline='') as file:
14441444
return csv.reader(file, delimiter=';')
14451445
```
1446+
* **If `'newline=""'` is not specified, then newlines embedded inside quoted fields will not be interpreted correctly.**
14461447

14471448
### Write Rows to CSV File
14481449
```python

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,9 @@ <h3 id="readrowsfromcsvfile">Read Rows from CSV File</h3>
12831283
<span class="hljs-keyword">with</span> open(filename, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
12841284
<span class="hljs-keyword">return</span> csv.reader(file, delimiter=<span class="hljs-string">';'</span>)
12851285
</code></pre>
1286+
<ul>
1287+
<li><strong>If <code class="python hljs"><span class="hljs-string">'newline=""'</span></code> is not specified, then newlines embedded inside quoted fields will not be interpreted correctly.</strong></li>
1288+
</ul>
12861289
<h3 id="writerowstocsvfile">Write Rows to CSV File</h3>
12871290
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_csv_file</span><span class="hljs-params">(filename, rows)</span>:</span>
12881291
<span class="hljs-keyword">with</span> open(filename, <span class="hljs-string">'w'</span>, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:

0 commit comments

Comments
 (0)