Leading zero-width no-break space in keys
See original GitHub issue- Operating System: Mac OS 10.14.5
- Node Version: 10.15.3
- NPM Version: 6.9.0
- csv-parser Version: 2.3.0
Expected Behavior
With a CSV looking like:
name,start_date,end_date
some - name,2019-08-25,2019-12-31
another - name,2019-08-05,2019-12-31
after parsing, accessing row.name should return a string
Actual Behavior
The row property doesn’t actually have name
, but rather name
preceeded by the utf char 65279, or a zero-width no-break space. I’ve created the CSV by hand, so I have no idea why that character would be in there
How Do We Reproduce?
fs.createReadStream(input_path)
.pipe(parse())
.on('data', (data) => console.log(data.name)) // undefined :(
.on('end', () => {});
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
How to Type a Zero-width Space for Perfect Line Breaks in ...
The zero-width space lets you handle tables with unpredictable or dynamic widths without breaking things up visually if the line doesn't have to ......
Read more >Non-breaking space - Wikipedia
Encodings. In Unicode, the Byte order mark (BOM), U+FEFF, may be interpreted as a "zero width no-break space", but is a deprecated alternative...
Read more >C# writes a ZERO WIDTH NO-BREAK SPACE at the ...
I have a text file that is written in C# using ascii encoding and when I attempt to read the file using a...
Read more >Variable-width non-breaking space in Word 2016 (including a ...
So far, I found a single solution: typing U+FEFF, then regular space, then U+FEFF again. U+FEFF is "Zero Width No-Break Space", so it...
Read more >'ZERO WIDTH NO-BREAK SPACE' causes issues with first ...
Specifically, this occurs because the whitespace character is included as part of the string in the header key collection so lookup by that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found this issue as well. The CSVs were created using Excel. First saved as xlsx, then as CSV. Printing the JSON.stringify() showed the header as
' USER_NAME'
instead of the expected'USER_NAME'
. I wasn’t able to get around this by modifying the CSV file, but I could instead trim the headers using the includedmapHeaders
function:I’m not a VS Code user, so I’m afraid you’d have to ask those folks. But you can use intermediate tools like https://github.com/sindresorhus/strip-bom and https://github.com/sindresorhus/strip-bom-cli to do that as part of the process.