Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 CSV file with BOM adds extra space character to first parsed field name #10

Closed
cormip opened this issue Jul 9, 2020 · 5 comments

Comments

@cormip
Copy link

cormip commented Jul 9, 2020

e.g. UTF-8 file with BOM:

id,varA,varB
1,0,0
2,0,0
3,0,0

imports as:

[
  {
    ' id': '1',
    varA: '0',
    varB: '0'
  },
  {
    ' id': '2',
    varA: '0',
    varB: '0'
  },
  {
    ' id': '3',
    varA: '0',
    varB: '0'
  }
]

I was able to work around this by converting the file to ANSI.

@sindresorhus
Copy link
Owner

This should be reported to the underlaying parser: https://github.com/mafintosh/csv-parser

@sindresorhus
Copy link
Owner

By the way, UTF-8 should not have a BOM.

@cormip
Copy link
Author

cormip commented Jul 10, 2020

The Unicode Standard permits the BOM in UTF-8, but does not require or recommend its use. I only ran into this because the export file created by Toad for MySQL was UTF-8 encoded with a BOM.

@dmikester1
Copy link

dmikester1 commented Aug 4, 2020

I'm running into this same issue! My column name should be "Chemical", but it's not matching "Chemical" because there is a character in front of it similar to a space but it's like a hidden space. Is there a work-around for this?

I'm not sure what BOM means, but it's just a CSV I saved out from Excel.

Look at the key field in this object:
image

@cormip
Copy link
Author

cormip commented Aug 4, 2020

BOM

Perform a Replace() function on the column name to remove all characters that don't belong. e.g. anything except a-zA-Z0-9 (or whatever else you need)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants