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

Reading a CSV file exported from Excel leaves UTF-8 BOM characters in file #7

Open
martinstreicher opened this issue Jun 10, 2021 · 1 comment

Comments

@martinstreicher
Copy link

martinstreicher commented Jun 10, 2021

I created a small Excel XLS file. I saved it and exported XLSX and CSV to use in a test suite for a Tabular-based POR utility class. I chose the UTF-8 CSV option from Excel to create the CSV.

When I read the file, the UTF-BOM remains in the first column name. You can see them from the byte-wise deconstruction of the column name.

(byebug) data.first.keys.first.to_s.bytes
[239, 187, 191, 99, 111, 108, 117, 109, 110, 95, 49]
(byebug) :column_1.to_s.bytes
[99, 111, 108, 117, 109, 110, 95, 49]

While I did save XLS as UTF-8 CSV instead of plain CSV, I'd still like the option to remove the BOM. I won't know whether other incoming CSV files will have the BOM or not.

@martinstreicher
Copy link
Author

Thoughts? I'm happy to send a PR. Specify format as utf8-csv to flag that the BOM needs to be removed?

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

1 participant