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
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -296,6 +296,32 @@ source stream can be done neatly with a modules such as:
296
296
Or native [`iconv`](http://man7.org/linux/man-pages/man1/iconv.1.html) if part
297
297
of a pipeline.
298
298
299
+
## Byte Order Marks
300
+
301
+
Some CSV files may be generated with, or contain a leading [Byte Order Mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8). This may cause issues parsing headers and/or data from your file. From Wikipedia:
302
+
303
+
>The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.
304
+
305
+
To use this module with a file containing a BOM, please use a module like [strip-bom-stream](https://github.com/sindresorhus/strip-bom-stream) in your pipeline:
306
+
307
+
```js
308
+
constfs=require('fs');
309
+
310
+
constcsv=require('csv-parser');
311
+
conststripBom=require('strip-bom-stream');
312
+
313
+
fs.createReadStream('data.csv')
314
+
.pipe(stripBomStream())
315
+
.pipe(csv())
316
+
...
317
+
```
318
+
319
+
When using the CLI, the BOM can be removed by first running:
0 commit comments