-
Notifications
You must be signed in to change notification settings - Fork 439
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
toArrays() of single field file appears to omit the final row #146
Comments
Simple solution. Add a newline at the end of the CSV file. This is actually spec behavior. I can also work out a solution to flush the last line if it isn't blank. I'm pretty sure I already solved this issue in @vanillaes/csv. |
Thanks for responding. Oh okay, if that is per specs then happy to close this issue. Compliance to specs is a big feature of this parser and is the main reason I chose this to utilitze it as the core parser in my project (Visual Field) - compared to other js parsing alternatives. I'm a little reluctant to implement your simple solution however, as Visual Field allows end users to provide either a delimited file as input or remote CORS delimited datasets as input (its not my own delimited or CSV input file). So, I am typically at the mercy of published datasets - and I don't really want to alter or mangle users raw input data in any way. I am curious however as to why there appears to be different parsing behaviour dependent upon the final input line being a single field or multiple fields without a trailing new line. For example, parsing a file of just "a" (without a new line) produces an empty array [] whereas, parsing "a","b" (without a new line) produces [["a","b"]]. Seems strange to me but if that behaviour is per specs, then that's fine. Thank you. |
TBH, the spec kind of sucks. It's not like CSV started with a well-defined spec. The RFC is more a list of common characteristics that make up a CSV file. Adding support for inputs that have no trailing newline isn't a big deal. I just need some time to patch and test. This codebase is very ugly because it was written prior to modern (ie ES6+) JS. As for your last question. I don't know, I'll have to see what it outputs once the first fix is in. Could be a very obscure bug that hasn't been discovered yet. |
Is this a bug? If not consider asking on StackOverflow.
Not sure if this is a bug or there is a workaround but this doesn't appear to be expected behaviour.
Subject of the issue
toArrays() of single field file appears to omit the final row
Environment
Steps to reproduce
Input;
Expected behaviour
Actual behaviour
References
The text was updated successfully, but these errors were encountered: