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: README.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,13 +142,17 @@ A `CSVReadder` parses CSV data from a given input (`String`, or `Data`, or file)
142
142
143
143
CSV fields are separated within a row with _field delimiters_ (commonly a "comma"). CSV rows are separated through _row delimiters_ (commonly a "line feed"). You can specify any unicode scalar, `String` value, or `nil` for unknown delimiters.
144
144
145
+
-`escapingStrategy` (default: `.doubleQuote`) specify the Unicode scalar used to escape fields.
146
+
147
+
CSV fields can be escaped incase they contain priviledge characters, such as field/row delimiters. Commonly the escaping character is a double quote (i.e. `"`), by setting this configuration value you can change it (e.g. a single quote), or disable the escaping functionality.
148
+
145
149
- `headerStrategy` (default: `.none`) indicates whether the CSV data has a header row or not.
146
150
147
151
CSV files may contain an optional header row at the very beginning. This configuration value lets you specify whether the file has a header row or not, or whether you want the library to figure it out.
148
152
149
153
- `trimStrategy` (default: empty set) trims the given characters at the beginning and end of each parsed field.
150
154
151
-
The trim characters are applied for the escaped and unescaped fields.
155
+
The trim characters are applied for the escaped and unescaped fields. The set cannot include any of the delimiter characters or the escaping scalar. If so, an error will be thrown during initialization.
152
156
153
157
- `presample` (default: `false`) indicates whether the CSV data should be completely loaded into memory before parsing begins.
154
158
@@ -236,6 +240,10 @@ A `CSVWriter` encodes CSV information into a specified target (i.e. a `String`,
236
240
237
241
CSV fields are separated within a row with _field delimiters_ (commonly a "comma"). CSV rows are separated through _row delimiters_ (commonly a "line feed"). You can specify any unicode scalar, `String` value, or `nil` for unknown delimiters.
238
242
243
+
- `escapingStrategy` (default: `.doubleQuote`) specify the Unicode scalar used to escape fields.
244
+
245
+
CSV fields can be escaped in case they contain priviledge characters, such as field/row delimiters. Commonly the escaping character is a double quote (i.e. `"`), by setting this configuration value you can change it (e.g. a single quote), or disable the escaping functionality.
246
+
239
247
-`headers` (default: `[]`) indicates whether the CSV data has a header row or not.
240
248
241
249
CSV files may contain an optional header row at the very beginning. If this configuration value is empty, no header row is writen.
// 3. If the retrieved scalar was a quote, retrieve the following scalar and check if it is EOF. If so, the field has finished and also the row and the file.
// 2. If the retrieved scalar is not the escaping scalar, just store it and continue parsing.
254
+
guard scalar == escapingScalar else{
255
+
field.append(scalar)
256
+
continue fieldLoop
257
+
}
258
+
// 3. If the retrieved scalar was a escaping scalar, retrieve the following scalar and check if it is EOF. If so, the field has finished and also the row and the file.
0 commit comments