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
Parser unable to parse csv file with lower row quantity compare with header #111
Comments
Hi, @EugeneLDT. Thank you for using this library. |
Hi @doyaaaaaken Thank you for response. I'm already found solution work around maybe will be helpful for someone. if your try to parse file demo.csv you got error. fun main() {
} |
@EugeneLDT |
Yes, it will be great. |
Thanks! |
Resolved in this PR #117 |
Describe the bug
Some csv editors after creating new fields add only touched fields
for example some csv editors on mac don't add extra empty fields:
For example we have csv file:
name,age,gender,hobby
Steve,19,male,sport
I'm will open this file and add one more user, but with empty gender, and hobby, in out business logic it's allowed.
name,age,gender,hobby
Steve,19,male,sport
Emma,20
editor will save latest record without extra empty fields, and parser with throw error something like
Fields num seems to be 4 on each row, but on 3th csv row, fields num is 2.
according configuration i'm can ignore or throw error in such case, but it's valid situation and. I'm need save this record.
To Reproduce
Steps to reproduce the behavior.
val record = mutableListOf<List>()
csvReader { charset = "UTF-8" quoteChar = '"' delimiter = separator }.open(file) { readAllAsSequence().forEach { record.add(it) } }
export file:
name,age,gender,hobby
Steve,19,male,sport
add one more user, and try to read this file
name,age,gender,hobby
Steve,19,male,sport
Emma,20
Actual behavior
Fields num seems to be 4 on each row, but on 3th csv row, fields num is 2.
Expected behavior
Reading file successful empty fields getting considered as empty one.
P.S. Will be good to add to class InsufficientFieldsRowBehaviour enum: IGNORE_MISSING_FIELDS
and handle it, like it some fields are missing just consider them as empty one.
Environment
Screenshots
If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: