You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/csv-module.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ with open(file_path, 'r', newline='') as csvfile:
44
44
This function returns a reader object which can be easily iterated over to obtain each row. Each column in the corresponding rows can be accessed by the index, without the need to use the built-in function [`split()`](https://www.pythoncheatsheet.org/cheatsheet/manipulating-strings#split).
45
45
46
46
## csv.writer()
47
+
47
48
This function receives the file to be written as a csv file, similar to the reader function, it should be invoked as this:
48
49
49
50
```python
@@ -59,6 +60,7 @@ with open(file_path, 'w', newline='') as csvfile:
59
60
60
61
The "do something" block could be replaced with the use of the following functions:
@@ -122,6 +125,7 @@ with open('people_dict.csv', 'w', newline='') as csvfile:
122
125
## Additional params to csv.reader() and csv.writer()
123
126
124
127
### delimiter
128
+
125
129
Should be the character used to separate the fields. As the file type says, the default is the comma ','. Depending on the locale, Excel might generate csv files with the semicolon as a delimiter.
126
130
127
131
```python
@@ -134,9 +138,11 @@ with open('data_semicolon.csv', newline='') as csvfile:
134
138
```
135
139
136
140
### lineterminator
141
+
137
142
Character or sequence of characters to end a line. Most common is "\r\n" but it could be "\n".
138
143
139
144
### quotechar
145
+
140
146
Character used to quote fields containing special characters (default is `"`).
0 commit comments