-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Spanish accents not parsing correctly when importing from CSV file to JSON #169
Comments
Is the file really UTF-8 encoded? (And are all its characters UTF-8 encoded as well?) If not, be sure to specify a proper encoding that includes all the characters found in the file. |
I think it has to do with the file reader not getting the encoding setting or with the jQuery select casing an issue. Here is my code <input type="file" id="csv-file" name="file"/> function handleFileSelect(evt) {
if ( !(evt.target && evt.target.files && evt.target.files[0]) ) {
return;
}
Papa.parse(evt.target.files[0], {
header: true,
dynamicTyping: true,
encoding: "UTF-8",
before: function(file, inputElem)
{
console.log(file);
// executed before parsing each file begins;
// what you return here controls the flow
},
error: function(err, file, inputElem, reason)
{
console.log(err);
// executed if an error occurs while loading the file,
// or if before callback aborted for some reason
},
complete: function (results) {
renderDataSet(results);
}
});
} |
I've confirmed that the file reader is indeed getting the encoding setting correctly. What's your input file look like? |
I'm saving the file as CSV |
I mean what are its contents? Until I can reproduce the problem I can't produce a fix. |
Ok the issue is with Microsoft excel it doesn't save it in UTF-8 format - http://stackoverflow.com/questions/4221176/excel-to-csv-with-utf8-encoding I just copied everything into google sheets and saved it there. |
Ah, good to know. You're not the first that has had that problem - for example, #64. Maybe I will make this an FAQ on the website. Glad you got it working! And thanks for your reports. |
Yea I would recommend adding this to the docs with some more info. |
Deleted my last comment, that Excel workaround does nothing... |
Had the same problem and lost a lot of time due to this weird Excel bug. What works for me: instead of exporting your Excel to CSV, save the file as .txt UTF-16 (found the solution lost in the middle of this stackoverflow thread http://stackoverflow.com/questions/4221176/excel-to-csv-with-utf8-encoding) |
Try to put a line like : encoding: "ISO-8859-1" in your papa config. |
Looked into this as I was using it, some notes that may help people:
|
I am still having trouble in loading the 2 CSV files correctly form this page: |
FWIW I've had success with using Encoding.js (https://github.com/polygonplanet/encoding.js) to detect some encodings including Japanese text (e.g. SJIS) and then run Papaparse based on that result. Be warned that Encoding.js says that it mainly supports Unicode and Japanese formats, and not other European-centric ones. ` <script type="text/javascript" src="./js/encoding.min.js"></script>function onFileSelect(event) {
} document.getElementById('encoding.js').addEventListener('change', onFileSelect, false); |
What user arebena said earlier worked for me with letters ä and ö that I needed.
|
I did export CSV from Excel (for Mac 16.9) using option "CSV - UTF8 (Comma delimited) (.csv)".
|
Thank you so much, you saved me! 2 weeks working on this... |
Hello, i also had this issue. What worked for me: open file in Microsoft Excel -> file -> save as -> choose "CSV UTF-8" as file type this should fix issues with utf-8 errors |
Worked for me! What A life saver |
encoding: "ISO-8859-1" works for me too, about french accents |
Don't be tempted to just change the encoding setting in excel and save as |
What version of excel did you use? Office 2011 for Mac just didn’t work with UTF8 for me, but I think the latest version worked ok? Not in my office so I can’t confirm my current version. |
The newest version of Excel, I believe it's 2019 on a Windows 10 PC. Good luck! |
Try this:
|
I've got a similar issue with generated CSV based on papa.unparse and french accents All fixes above applied to no avail. const BOMprefix = "\uFEFF";
new File([`${BOMprefix}${csvString}`], csvFileName, { type: 'text/csv;charset=utf-8;' }); |
It worked for me, with the Arabic language, thank you for sharing this solution |
It solves the problem of recognizing special characters however some cases are still missed out and utf8 characters are still not parsed correctly sometimes. Using the below typescript solution I am now reading the CSV as text and it works for all utf8 characters.
|
I'm parsing a CSV file with spanish accents, I set the encoding to UTF-8 however it's not parsing correctly
Here is what I'm getting back in the results object
name: "GREGORIO BERNABE �LVAREZ"
and I have the following config setup
Papa.parse(evt.target.files[0], {
header: true,
dynamicTyping: true,
encoding: "utf-8",
}
The text was updated successfully, but these errors were encountered: