* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
* **`'endline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
### Modes
### Modes
* **`'r'` - Read (default).**
* **`'r'` - Read (default).**
@ -1438,14 +1439,14 @@ import csv
### Read Rows from CSV File
### Read Rows from CSV File
```python
```python
def read_csv_file(filename):
def read_csv_file(filename):
with open(filename, encoding='utf-8') as file:
with open(filename, encoding='utf-8', newline='') as file:
return csv.reader(file, delimiter=';')
return csv.reader(file, delimiter=';')
```
```
### Write Rows to CSV File
### Write Rows to CSV File
```python
```python
def write_to_csv_file(filename, rows):
def write_to_csv_file(filename, rows):
with open(filename, 'w', encoding='utf-8') as file:
with open(filename, 'w', encoding='utf-8', newline='') as file:
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <codeclass="python hljs"><spanclass="hljs-string">'encoding="utf-8"'</span></code> whenever possible.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <codeclass="python hljs"><spanclass="hljs-string">'encoding="utf-8"'</span></code> whenever possible.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'endline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'newline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
</ul>
</ul>
<h3id="modes">Modes</h3>
<h3id="modes">Modes</h3>
<ul>
<ul>
@ -1278,12 +1279,12 @@ value = args.<name>
</code></pre>
</code></pre>
<h3id="readrowsfromcsvfile">Read Rows from CSV File</h3>
<h3id="readrowsfromcsvfile">Read Rows from CSV File</h3>